This is a textbook example of "undefined behaviour". It gives different results on different machines because, well, there's a bug and there is no way to predict when or how it will "work" or fail.
Inside the j loop, xyz is not properly terminated as a string.
To be clear, it is not an issue with the sandbox. It is a garden variety bug.
"Ready, fire, aim!"
The problem lies here:
jpg = fopen(filename, "w");
sprintf(filename, "%03i.jpg", numfound);
The sprintf command builds the name of the file to be opened by the fopen call. It needs to be before the fopen call.
It also explains the files with wierd file names. To delete them, you'll need to ...
Welcome to the community. Your program is a real mess of functions for a relatively simple task, the purpose of the use of functions is to perform specific tasks outside of main (), in order to keep the code readable, that the logical flow is easy to follow. Five functions for Vigenere seem excessive to me. Well, everything is a matter of preferences.
You read the first 512 bytes (I used an array of uint8_t instead of int, but that should be possible as well), and print the first integer, representing the first 4 bytes.
If you throw card.raw int the hex viewer, you'll see the first 512 bytes really are all-zeros:
~/workspace/freestyle/ $ xxd -l 512 -g 8 -c 32 card.raw ...
According to this answer on Stackoverflow, the function time is normally passed a pointer to a time_t object (or struct) which it fills up with the current time. If you pass it null, however, you will just be handed the current time.
So srand48((long int)time(NULL)) can be translated to (in English):
Call srand48 with the current time reported by 'time' ...
This may not be the only problem, but I stopped reading here: int key = atoi(argv);. From the transcript of the Command-Line Arguments Short in Week 2:
This means that each element in argv, starting from zero, contains the command and arguments. For example, argv, which I'll refer to as argv zero, will always contain the command that is being run-...
I've seen that a couple of times lately. Here's what I believe is happening. When you create a pointer without initializing it, it will contain whatever random garbage data happens to be in the memory location of the variable (not to be confused with what it points at.) Note that NULL is represented by binary 0. In a newly started computer's memory, or one ...
You have the following code block at the end of your while loop:
// if jpeg already open
else if(open == 1)
img = fopen(name, "a");
if (img == NULL)
fprintf(stderr, "Could not append %s.\n", name);
fwrite(buffer, 512, 1, img);
It checks to ...
NULL is expanded from a macro (a preprocessor #define), which is usually defined as:
#define NULL ((void*)0)
which means that it's defined as a pointer. Basically, it's the same thing. When you declare a pointer as NULL, you're actually storing the value 0 in it, so it's basically the same thing. Underneath the hood 0, '\0' and NULL all have a value of 0.
Whatever you put inside the parenthesis is considered/has to be a condition. So it could be while (a == 5) or if a variable is itself a condition you can put the variable directly in the parenthesis. For example every integer, except for 0, is considered as true, so if I have while (10) this condition will always be true (and will probably cause an infinite ...
The problem is because you're allocating the wrong size for root
root = malloc(sizeof(root));
the size of root is typically 4 bytes on 32-bit systems. You actually need to allocate sizeof node which is typically 1 (for is_word) + 27 * 4 (for children) + 3 (padding) = 112 bytes.