char output;
float sum;
int N,K;
sprintf(output,"%f",sum/(N-K));
[Warning] passing arg 1 of `sprintf' makes pointer from integer without a cast
char output;
float sum;
int N,K;
sprintf(output,"%f",sum/(N-K));
[Warning] passing arg 1 of `sprintf' makes pointer from integer without a cast
needs a size.. likeCode:char output;
the error you pasted I don't really get although the compiler I just used does suck....Code:char output[50];
"output" is an integer while sptrinf() needs a pointer type.Originally Posted by Sysop_fb
Although gcc's (i suppose this ist gcc) error messages are crap sometimes, this one is quite clear imho.
Btw: Hi board
what?Originally Posted by TactX
I don't use gcc
and sprintf doesn't need a pointer and he didn't declare "output" as an integer.
You didn't really word yourself very well there..
Code:int sprintf(char *string, char *format, ...)
What would you call a char* then if not pointer? And a char is an integer type.Originally Posted by Sysop_fb
I think you need to brush up on your data types...You're wrong on both points.Originally Posted by Sysop_fb
If you understand what you're doing, you're not learning anything.
Well then I'm confused yes...
char *string is a pointer to a char
But you can pass it a character array in which case the pointer is set to the character array or pass it a pointer whatever... he said it HAD to be a pointer even though pointers and arrays are very closely tied together in C.
Okay a char data type belongs to the family of interger data types... but when I see someone say so-and-so is decalred as an integer I think of int instead of some all encompassing integer type, I like being more specific.
Last edited by Sysop_fb; 10-03-2005 at 02:39 PM.
When you pass an array to a function you're passing a pointer to the first element in the array. foo(string) is equivalent to foo(&string[0]) when string is an array if that makes it clearer for you. So even when the original datatype is an array you're still passing a pointer to the function.
If you understand what you're doing, you're not learning anything.
Didn't know that! Although it makes sense...Originally Posted by itsme86
Thanks!