Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Unseen error
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Alan Coopersmith, post: 1693994"] [email]hpy_awad@yahoo.com[/email] (hpy_awad@yahoo.com) writes in comp.unix.solaris: |I wrote that example from a book and there is en error in the display |module that it does not showing all the records are entered in the |input module. |I traced with some printf statments without getting the solution . I |think the error in the display module loop condition. Could that be because you limit the display to only the first two records in the display module? | } while (i<=2); That seems incredibly obvious, especially since you identified that as the possible problem. |init_player(player) |//------------------ |struct football player[]; If you're just learning C now, get a new book that teaches you ANSI C (aka C89) and not the ancient K&R style which is long obsolete and will only cause you problems with modern compilers. | for (j=0;j<30;++j) | { | player[i].name[j]=' '; | player[i].team[j]=' '; | } There's no '\0' at the end of those strings, so attempts to print them may include random garbage at the end, or anything else. It would be much better to simply do: player[i].name[0] = '\0'; player[i].team[0] = '\0'; Or use memset() if you want to clear the entire string length to 0. |do |{ | ++i; | | //input a character | alpha[i]=getchar(); |} while (alpha[i] !='\n' && i<29); This could be written more simply with fgets()[/i][/i][/i][/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Unseen error
Top