Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 20, 2013, 12:00 PM   #1
farmerdoug
macrumors 6502a
 
Join Date: Sep 2008
odd warning

Code:
int i, *tension;
tension = (int *) calloc(MAX_READINGS, sizeof(int));
if (fscanf(readings,"%s %d\n", reading_times[0], tension[0]) == EOF)

Last edited by OllyW; Jan 20, 2013 at 12:29 PM. Reason: fixed code tags
farmerdoug is offline   0 Reply With Quote
Old Jan 20, 2013, 12:17 PM   #2
ArtOfWarfare
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
You didn't tell us what warning you're getting and we don't know anything about your reading_times[] variable.
ArtOfWarfare is offline   0 Reply With Quote
Old Jan 20, 2013, 12:31 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
fscanf() requires pointer-to-int for %d. What type is tension[0]?
chown33 is offline   0 Reply With Quote
Old Jan 21, 2013, 05:50 AM   #4
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
thanks guys.
I found the error while writing the post but couldn't find out how to delete it. I left out the & in front of tension[0].
farmerdoug is offline   0 Reply With Quote
Old Jan 21, 2013, 11:08 AM   #5
subsonix
macrumors 68030
 
Join Date: Feb 2008
You probably do not want to test against EOF in *scanf functions, they return EOF only under very special circumstances. If you test against != 2, you will catch read errors and all other cases.
subsonix is offline   0 Reply With Quote
Old Jan 21, 2013, 11:08 AM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by farmerdoug View Post
thanks guys.
I found the error while writing the post but couldn't find out how to delete it. I left out the & in front of tension[0].
MacRumors FAQ: How do I edit or delete my post?

To avoid having people answer or ask follow-up questions in the interval before the post is deleted, simply replace your entire post with the word "delete".
chown33 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:57 AM.

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

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