944,181 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1836
  • C RSS
Aug 6th, 2007
0

my program dont run good...array of structures in c...i used dev-c++

Expand Post »
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct courses{
  5.  
  6. char coursenumber[10];
  7. float credit;
  8. float grade;
  9. };
  10.  
  11. struct courses list[2];
  12.  
  13. main()
  14. {
  15.  
  16. int i;
  17. int count;
  18.  
  19. printf("Enter number of courses to input: ");
  20. scanf("%d", &count);
  21.  
  22. for (i=0; i<2; i++)
  23. {
  24. printf("Course number: ");
  25. scanf("%s", list[i].coursenumber );
  26. printf("Credit: ");
  27. scanf("%f", list[i].credit);
  28. printf("Grade: ");
  29. scanf("%f", list[i].grade);
  30. }
  31.  
  32. printf("\n\n");
  33.  
  34. for (i=0; i<2; i++)
  35. {
  36. printf("%s", list[i].coursenumber);
  37. printf("%f", list[i].credit);
  38. printf("%f", list[i].grade);
  39. }
  40. return 0;
  41.  
  42. }
Last edited by Ancient Dragon; Aug 7th, 2007 at 7:47 am. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mona1nine is offline Offline
2 posts
since Aug 2007
Aug 6th, 2007
0

Re: my program dont run good...array of structures in c...i used dev-c++

What's your question?.

Post what is this program suppose to do. What kind of malfuntions it
has, what copiling errors you recieve, etc, etc,...
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Aug 6th, 2007
0

Re: my program dont run good...array of structures in c...i used dev-c++

Click to Expand / Collapse  Quote originally posted by Aia ...
What's your question?.

Post what is this program suppose to do. What kind of malfuntions it
has, what copiling errors you recieve, etc, etc,...
this program has to gather all the subjects, grades and credits of the students. and be able to display it in columnized.

when i compile it... it compiles but when i run it in cmd... while entering the info it will stack and porst error messae like (dont send)....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mona1nine is offline Offline
2 posts
since Aug 2007
Aug 6th, 2007
0

Re: my program dont run good...array of structures in c...i used dev-c++

Click to Expand / Collapse  Quote originally posted by mona1nine ...
when i compile it... it compiles but when i run it in cmd... while entering the info it will stack and porst error messae like (dont send)....
You are forgetting to write the & operator in all the scanf() that are not strings.
Example:
scanf("%f", &list[i].credit); needs it. Any thing that is not
printf("%s", list[i].coursenumber);
Last edited by Aia; Aug 6th, 2007 at 11:00 pm.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: advice for this code
Next Thread in C Forum Timeline: .exe





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC