does anyone know why this doesnt work?
char BaseFileName[] = "soemthing%s";
char FileNameA[255];
sprintf(FileNameA,BaseFileName,"more");
sorry to do this, but i have to make this work by the end of the day... and i cant get it
does anyone know why this doesnt work?
char BaseFileName[] = "soemthing%s";
char FileNameA[255];
sprintf(FileNameA,BaseFileName,"more");
sorry to do this, but i have to make this work by the end of the day... and i cant get it
I'd go for:
Code:char BaseFileName[] = "something"; char FileNameA[255] = {0}; sprintf (FileNameA, "%s%s", BaseFileName, "more");
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd
Define "doesn't work". Are you sure it's not working? Did you print the string?
It doesn't? What doesn't work about it...?does anyone know why this doesnt work?
It's a fairly simple line of code, and I'm not seeing anything wrong with it.
It compiles and seems to work correctly...
(You are aware you're using sprintf, and that sprintf() doesn't output anything to stdout?)
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
You must be doing something else wrong, because there is nothing obviously wrong with those 3 lines.
Try them in a 3 line program, and confirm it for yourself.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
sorry.. by doesnt work i meant doesnt compile
Sorry i posted a silly quesiton like that on the board, but here is a good question
i found the problem .. but i dont understand why its happening.
I have noticed this many times before too.
If i put a command in the middle of my initialization of variables my program wont compile... why is that?
ie.
char face9[255];
face9="w00t";
int i;
//now my program would be broken
When you take the name of an array by itself, it's taken as a pointer to the first element, however it's considered const in the sense that you can't make it point to somewhere else. It can't be an lvalue in an expression (ie. nothing can be assigned to it).
Arrays can only be initialized during declaration.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
ok.. well that was just me making a bad example.. sorry
lets use an easy one
int i,k;
i=9;
k=i*9;
short P;
//now my program doesnt work because i did operations before i finished all of my declarations.