3
votes
segmentation fault, probably because of sprintf
String literals (e.g., 000.jpg) are constant expressions. They are read-only. When assigning a string literal to a variable of type char *, you get a memory address stored in that char * variable that ...
3
votes
sprintf compile error
You're doing something else wrong. While you want to put a string into title, you're actually trying to put the return value from sprintf() into title and to put the contents of counter into a ...
2
votes
Accepted
sprintf compile error
See the man page for sprintf here: https://reference.cs50.net/stdio.h/sprintf
The function takes two arguments. This particular call to sprintf requires a third because the format has a variable in ...
2
votes
segmentation fault, probably because of sprintf
char* outfile = "000.jpg";
Actually your sprintf function looks good. I think this line is where the problem is. You've assigned outfile the address of a string literal, which will be automatically ...
1
vote
Accepted
a problem with sprintf in recover
Your file name is 7 characters long, so plus the null terminator, your filename variable should point to a memory block of at least 8 characters, not 3.
What happens is that sprintf prints to memory ...
1
vote
Accepted
sprintf messing up with my int counter (converting it to an address?)
The problem lies in your declaration of imagenr.
char imagenr = 0;
This creates a variable that holds a single character, not a string. Later, with the sprintf() call, the code copies an 8 char ...
1
vote
Accepted
About sprintf function
When you declare the char array, as char buffer[8], you are creating an array that holds 8 characters. (This should generally be large enough to include the \0 end of string character, but that's ...
1
vote
pset6 server.c problem with sprintf() not substituting for the query string
I solved this myself. The problem, of course, had to do with incorrect pointer use. I had created a fcn to parse out the query string. I parsed the query string into a local variable, and then set ...
Only top scored, non community-wiki answers of a minimum length are eligible