Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

007bond

macrumors 6502a
Original poster
Dec 12, 2008
560
1
DFW, Texas
This is part of my code:

Code:
int main(){

	char str[100];
	char min[100];
	char max[100];
	int count;
	int num = 0;
	
	scanf("%i", count);

On the line with "scanf", I get the error " warning: format ‘%i’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat]" (I'm using a unix-based compiler, if that helps).

I'm reading in data from a file with this data:
Code:
7
jones
smith
aki
ren
stimpy
bart
Simpson
 
Last edited by a moderator:

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
You need to give scanf the address of an int so scanf can set its value. Pass &count rather than count.

-Lee
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Wow...I feel really stupid right now. Thanks for the help!

Well, the error message was pretty spot-on. :)

"warning: format ‘%i’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat]"
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.