Questions tagged [sprintf]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
2 answers
3k 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 ...
user avatar
  • 151
1 vote
2 answers
214 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: ...
user avatar
  • 82
1 vote
1 answer
223 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 ...
user avatar
  • 21
0 votes
1 answer
271 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"); ...
user avatar
  • 62
0 votes
1 answer
100 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 ...
user avatar
  • 47
0 votes
1 answer
204 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> ...
user avatar
  • 17
0 votes
1 answer
48 views

pset1 credit; buffer overflow when converting to char array

My initial idea for the credit problem was to convert the long from get_long into a char array, in order to obtain something iterable to get each digit for Luhn's algo. I recognize that this could be ...
user avatar
0 votes
1 answer
114 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 ....
user avatar
  • 9
0 votes
1 answer
286 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 ...
user avatar