954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

#include <stdio.h>
#include <string.h>

struct courses{

       char coursenumber[10];
       float credit;
       float grade;
};

struct courses list[2];

main()
{

int i;
int count;

     printf("Enter number of courses to input: ");
     scanf("%d", &count);
     
for (i=0; i<2; i++)
{
     printf("Course number: ");
		 scanf("%s", list[i].coursenumber );
     printf("Credit: ");
		 scanf("%f", list[i].credit);
     printf("Grade: ");
		 scanf("%f", list[i].grade);
}  
     
     printf("\n\n");

		 for (i=0; i<2; i++)
     {
		 printf("%s", list[i].coursenumber);
         printf("%f", list[i].credit);
         printf("%f", list[i].grade);
}
     return 0;

}
mona1nine
Newbie Poster
2 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

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
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
 

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)....

mona1nine
Newbie Poster
2 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 
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);

Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You