Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 6, 2013, 10:47 AM   #1
007bond
macrumors 6502a
 
007bond's Avatar
 
Join Date: Dec 2008
Location: DFW, Texas
Basic C Programming Question - Can anyone help?

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
__________________
LG Nexus 5 White; iMac 27" 2009 3.06 GHz Core 2 Duo; 2014 MacBook Air 13"

Last edited by balamw; Feb 6, 2013 at 01:16 PM. Reason: QUOTE->CODE
007bond is offline   0 Reply With Quote
Old Feb 6, 2013, 11:25 AM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
You need to give scanf the address of an int so scanf can set its value. Pass &count rather than count.

-Lee
lee1210 is offline   0 Reply With Quote
Old Feb 6, 2013, 12:29 PM   #3
007bond
Thread Starter
macrumors 6502a
 
007bond's Avatar
 
Join Date: Dec 2008
Location: DFW, Texas
Quote:
Originally Posted by lee1210 View Post
You need to give scanf the address of an int so scanf can set its value. Pass &count rather than count.

-Lee
Wow...I feel really stupid right now. Thanks for the help!
__________________
LG Nexus 5 White; iMac 27" 2009 3.06 GHz Core 2 Duo; 2014 MacBook Air 13"
007bond is offline   0 Reply With Quote
Old Feb 6, 2013, 01:15 PM   #4
LPZ
macrumors 65816
 
Join Date: Jul 2006
Quote:
Originally Posted by 007bond View Post
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]"
LPZ is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Programming on iPad with "smart BASIC" kibernetik iPad Apps 13 Nov 20, 2014 08:03 AM
Snow Leopard File Vault Question and Basic System Password Question & Time Machine? GordonGekko999 Mac Basics and Help 0 Oct 25, 2013 07:06 AM
Basic c programming help Rudd999 Mac Programming 6 May 10, 2013 09:52 PM
Really basic iMessage question! zachnelson iOS 6 5 Jun 16, 2012 07:26 AM
Basic question about iCloud Loa iCloud and Apple Services 11 Jun 12, 2012 04:46 PM

Forum Jump

All times are GMT -5. The time now is 10:38 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC