Questions tagged [sprintf]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
244 views

a problem with sprintf in recover

#include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc, char *argv[]) { // check arguments if (argc != 2) { fprintf(stderr, "USAGE: ./recover raw_file\n"); ...
0
votes
1answer
77 views

sprintf messing up with my int counter (converting it to an address?)

While playing around with sprintf to figure out how to make it work before adding it to my recover.c code, I ran into a weird (at least for me) situation. I declare a counter variable (int type), use ...
0
votes
1answer
104 views

pset4 recover not naming the first file correctly?

This is an odd one. I've managed the get the code to work and output all 50 jpgs as expected with the exception of the first one. It's creating the file but not naming it correctly (not even adding ....
0
votes
1answer
271 views

Hacker pset1 credit.c always gives invalid?

I tried to attempt the credit.c problem. My code is as follows: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> int main(void) { printf("Please ...
1
vote
2answers
201 views

sprintf compile error

I seem to be having a problem with sprintf, the compiler gives me an error. char* title = sprintf("%03d.jpg", counter); The above gives me the following response in the compiler: recover.c:39:39: ...
0
votes
1answer
185 views

About sprintf function

May someone explain me what the '8' of the buffer variable means? I know here involves arrays but I am not clear what is implied if the number is for example changed to 30. #include <stdio.h> ...
1
vote
1answer
219 views

pset6 server.c problem with sprintf() not substituting for the query string

For the php section, my sprintf is not working correctly to substitute the query string and is causing a "PHP Notice: Undefined index: name...". The path substitutes in just fine. It is rather ...
2
votes
2answers
2k views

segmentation fault, probably because of sprintf

for my recover.c i have trouble changing the filenames. I get a segmentation fault probably because of incorrect usage of sprintf. Code looks sort of like this: { // pseudocode for testing ...