Previous thread: What are you working on Sup Forums?
/dpt/ - Daily Programming Thread
Other urls found in this thread:
github.com
mellanox.com
twitter.com
>What are you working on
that's a lot of technical words
Not really, if you know the basics of PCI and how pass-through works, you should be able to understand that.
try this
int main()
{
char** arr = malloc(51*sizeof(char*));
int i, j;
for(i = 0; i < 51; i++){
arr[i] = malloc(51*sizeof(char));
}
arr[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX";
printf("%s\n", arr[0]);
for(i = 1; i < 51; i++){
arr[i][0] = arr[i-1][49];
for(j = 1; j < 50; j++){
arr[i][j] = arr[i-1][j-1];
}
printf("%s\n", arr[i]);
}
}
Start programming in C.
That's undefined behaviour.
POST A SCREENSHOT OF YOUR CODE
I didn't even compile it. i'm sure you can get the basic idea from it, just think about it until you get it.
dumb frogposter
That's undefined behaviour.
Making arr[0] point to a string literal, then trying to modify that string literal will make your program segfault.
...
idiot
I'm working on a control algorithm for a 7-dof robotic manipulator. Once I get the IK and joint torques fleshed out I want to train a DNN that will provide visual end effector data so I can push my steppers faster without worrying about step loss by using that data in closed feedback loop. Point being I want to reduce the size of manipulator by removing encoders. I'll have a camera for object identification so I might as well pull that data into a kalman filter with my kinematic model and only use those for orientation control. After I get that working, I'd like to also use the same camera for path planning and obstacle avoidance as an end of project milestone.
But you get the basic idea. Just try copy the value. I barely program in C but I’m pretty sure it has stringCopy() or something like that.
would you help me with this project if i paid you in crypto?
im stuck and im battling the flu right so its hard to think
Not everyone can be as smart as you.
can't violate my NDA ;)
I like puzzles like this. I’ll do it for free
;_;
what should be done?
what NDA you neet?
...
You need a (final) solution.
Like I said I’m not too familiar with C but you need something like StringCopy() (I think that’s what it’s called) that copies the value. I did something like this in a C class I took last year
...
whast your discord?
yuiHorie#5838
messaged,thanks
Something like this:
#include
int main()
{
int i, j, pos;
const char alphabeth[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char arr[sizeof(alphabeth) - 1][sizeof(alphabeth)];
for (i = 0, pos = 0; i < (sizeof(alphabeth) - 1); ++i, ++pos)
{
for (j = 0; j < (sizeof(alphabeth) - 1); ++j)
{
arr[i][j] = alphabeth[(j + pos) % (sizeof(alphabeth) - 1)];
}
arr[i][j] = '\0';
}
for (i = 0; i < sizeof(alphabeth); ++i)
{
puts(arr[i]);
}
return 0;
}
What's a monad
Just realized that pos is redundant. Replace all instances of pos with just i.
A monoid object in an endofunctor category.
A burrito
how did you solve this that fast wtf
this looks correct, thanks man, im going to try and impliment it
I am trying to run this. I have no experience with ruby. There is an usage example, but where do I type that? I cannot run it as it is. The regular terminal or the irb won't work, and there is no obvious file to run directly.
Can someone spoonfeed a bit?
>how did you solve this that fast wtf
Because I'm this guy:
Is Haskell the cutest programming language?
Functional programming is a meme.
I'm sorry I guess
aqua is dumb
Here's a version that is better.
#include
int main()
{
int i, j;
const char alphabeth[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char arr[sizeof(alphabeth) - 1][sizeof(alphabeth)];
for (i = 0; i < (sizeof(alphabeth) - 1); ++i)
{
for (j = 0; j < (sizeof(alphabeth) - 1); ++j)
{
arr[i][j] = alphabeth[(j + i) % (sizeof(alphabeth) - 1)];
}
arr[i][j] = '\0';
}
for (i = 0; i < sizeof(alphabeth) - 1; ++i)
{
puts(arr[i]);
}
return 0;
}
I realized that I'm shifting the wrong way around, but you should be able to figure out the correct way on your own though.
I want to get back into programming and fucking around in linux and security. Its been about 2 years since I've done anything with programming with the exception of my year at a uni. A year out and $10,000 later Im finally realizing that my best chance at not living a shitty life is going to be in a field I enjoy as I cant do much physical labor as Im fucking disabled.
Now im not sure how Im going to proceed to getting a job or experience I cant afford college and i've thought about just ending it.
Why are you still doing backend stuff anons? Everyone knows front end is more difficult and always changing
In C++, when I press certain keys I want to invoke certain functions.
I have something like this
std::map keyfunctions;
Right now I have func defined as
using func = int (*)();
I want to have it execute a function that belongs to a class, which would be of type
int (Class::*)();
How can I handle such a scenario?
...
using func = int (*)(); // keep as is, although std::function is better
class MyClass
{
public:
int function() {
return 2;
}
};
MyClass m;
auto func = std::bind(MyClass::function, m);
keyfunctions[keycode] = func
Use function pointers as values for the map.
Anime shitposting gets answers,
but questions about programming don't?
can i pay you to tutor me
You should use std::function. as-is won't work because function pointers aren't closures.
Why don't you just strcpy it?
#include
void pushcopy(char const * src, char * dst)
{
int lng = strlen(src);
strcpy(dst, (src + 1));
dst[lng - 1] = src[0];
dst[lng] = 0;
}
int main()
{
char const template = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i;
int const lenght = strlen(template);
char arr[lenght + 1][lenght];
strcpy(arr[0], template);
for( i = 1; i < sizeof(template); i++)
{
pushcopy(arr + ((lenght +1)* (i - 1)), arr + ((lenght + 1) * (i));
}
}
I'm not quite sure if I use char var[][], then access it trough var[i] will return a pointer or a char in var[i][0], that is why I use the arr + lenght
I wouldn't have time to do that, sadly. My schedule is too full.
ill pay you $50 in btc for an hour of your time tonight
Ignore this. A kinder user already answered.
Because everyone watch anime, and barely know ruby.
Get a better meme-lang then we will answer immediately
>Why don't you just strcpy it?
You can do that. I saw no reason to do it in my code, but there's no reason you shouldn't do that if you think that's better.
Yes, you are right. My brain stopped working for a second. You're absolutely right, it needs to be
using func = std::function;
I think.
Tempting, but I'm going to bed in 5 minutes. Good luck to you though, if you just put in some effort you're going to get better at it quite quickly.
People on this board like to pretend that C is hard, probably because it makes them feel special about their own abilities, but it really isn't that hard. It's just that you need to do some stuff manually because a bunch of neat features weren't conceived of in the 70s and you need to be aware of undefined/unspecified behaviour, and that's pretty much it.
night, thank you for the help
Give me one good reason why Python's forced syntax is a bad thing.
>bad thing
It isn't. The only thing I dislike about Python is that it doesn't use UTF8 strings by default. Maybe this is fixed in Python 3?
Its not. Use a better scripting language like Ruby
Makes it difficult to have block expressions like lambdas.
Thanks that worked well.
is this from a videogame?
Can I use the dropbox api to write code in HTML to save a canvas to a png in a dropbox?
If so, can someone walk me through it?
No, it's from the textbook and reference guide to the Haskell language:
Learn you a Haskell for Great Good!
Didn't quite get it to work. There's still a race condition between the end of thread A adding an element to Queue_B and thread B setting its waiting flag to false. Note that both queues can be empty without there being a deadlock, so I can't use that criteria either.
I think I'll leave it at this, I just thought you might have a comment. (inc_queue_agg is a different object for each thread)
else if (op_code == "rcv"s) {
std::unique_lock lock(inc_queue_agg.m);
const auto timeout = std::chrono::milliseconds(500);
while (inc_queue.empty()) {
this_waiting = true;
if (that_waiting)
return;
inc_queue_agg.cv.wait_for(lock, timeout);
}
this_waiting = false;
registers[sX] = inc_queue.back();
inc_queue.pop_back();
}
>There's still a race condition [...]
, by which thread A can erronously reach the return statement on its side.
How do large scale HPC clusters usually manage data storage and synchronization? Do they use some sort of specialized database software?
user, what license is the most non-restricting, and easiest to implement?
I have a small self-made tool collection that I usually use personally, but my friend's company want to use it for their office, and they keep asking me for "what license did you use" even tough I told them that it's free and they can use it whatever they want.
I don't really care what will they do to my code since I wrote that without any intention to monetize it.
MESSAGE PASSING INTERFACE YOU FOOL
Yes. It highly depends on the application though.
is it possible in x86 assembly to assign the value of a 8 bit register into a DW?
MPL pretty much does what you want. It requires people who use it in proprietary programs to disclose their changes. This works if you care less about it being monetized over getting them to contribute back (after all, if there's money involved, it means faster progress, right?).
MPI is a communications protocol, not a storage backend.
Could you link to any examples? Just trying to get more familiar with the area.
>Could you link to any examples?
mellanox.com
Thanks!
yeah, well your mother is shared resource
So sick of waiting fruitlessly for c++ features that will never appear
Maybe c++36 will have coroutines, ranges, concept and metaprogramming
Maybe I'll be dead by then
>tfw you sperg out about lisp but do it in cool way so now everybody thinks you know something about this mystic ancient language
fuck normies
learn Haskell
What's a DW, Double Word? movsx.
>Maybe c++36 will have coroutines, ranges, concept and metaprogramming
boost already does i'm sure
Stop trying to use one language for everything, sepples is already a fucking nightmarish blob of feature creep bullshit. Learn how to have languages talk to each other.
Inconsistent between users. Trailing spaces are not recognizable and literally break the program. It makes it incredibly hard to follow because you have to rely exclusively on indentation instead of clear bracketing indicating new inner scopes. One errant space, either too few or too many, breaks the entire program.
>inb4 BUT DATS WHAT DA EDITOR IS 4
Yeah its syntax, the editor isnt supposed to be fucking fixing that for you out of necessity. It should only be doing that for consistency.
What is the best method to split up the translation unit for templated function and class?
Having all function dumped on the header is weird, but template can't be splitted to other translation unit
using func = std::function;
std::map funcs;
funcs = std::bind(Class::method, instance);
I want language features not library pretending to be language features (see: std::tuple)
>wanting to bloat your language
B-but all my uni classes use Java and C/C++ requires setup+IDE's for dev.
how can I learn this stuff?
>C/C++ require setup+IDEs
Nigger what
I did all of my uni's C courses in fucking nano
C specification only specify integer type datatype as "minimum able to store number from here to here", and doesn't tell the exact width of the datatype.
Does that mean a compiler that convert all integer datatype to long long int or unsigned long long int is still a valid C compiler?
Doesn't that makes lots of code broken?
You can fake it by having a "template translation unit" that is actually a header included at the bottom of a declaration-only header.
>Does that mean a compiler that convert all integer datatype to long long int or unsigned long long int is still a valid C compiler?
yes
>Doesn't that makes lots of code broken?
lots of poorly-written code, yes
>Does that mean a compiler that convert all integer datatype to long long int or unsigned long long int
Be careful here. The types will still be different and follow all the standard conversion rules. The compiler is only allowed to specify widths for the types, with some constraints.
If a program relies on implementation-defined behaviour, yes, it may be broken on different compilers. But that's because it's just broken in general and "works on my machine".
a number from "here to here" is defined as said type of int.
A unsigned int and a signed int are the same width, 2 bytes. From 0 to 65,535 or the corresponding signed -32,767 to 32,767
A long is 32 bits (4 bytes)
A long long is 64 bits (8 bytes)
etc etc
It's all binary, numbers are all represented in the same widths, its just a matter if you mean int16, int32, int64, etc
guess you don't know much about C, huh