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

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2007
Posts: 2
Reputation: mona1nine is an unknown quantity at this point 
Solved Threads: 0
mona1nine mona1nine is offline Offline
Newbie Poster

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

 
0
  #1
Aug 6th, 2007
  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,033
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

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

 
0
  #2
Aug 6th, 2007
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,...
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 2
Reputation: mona1nine is an unknown quantity at this point 
Solved Threads: 0
mona1nine mona1nine is offline Offline
Newbie Poster

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

 
0
  #3
Aug 6th, 2007
Originally Posted by Aia View Post
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)....
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,033
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

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

 
0
  #4
Aug 6th, 2007
Originally Posted by mona1nine View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC