|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||
|
|
|
|||
|
i have changed somethings in your source code and i think it looks ok now...try this...
#include <stdlib.h> #include <stdio.h> #include <conio.h> main() { char name[30], sex[2]; int n, counter, age; double gpa; FILE *inp, *outp; inp = fopen("stdlist.txt", "r"); outp = fopen("stdlist.dat", "w"); printf("How many students: "); scanf("%d", &counter); n=1; do { printf("Please enter student's name:"); scanf("%s",name); printf("Please enter student's sex (M or F): "); scanf("%s", sex); printf("Please enter student's age: "); scanf("%d", &age); printf("Please enter student's GPA: "); scanf("%lf", &gpa); system("cls"); printf("\n\n----------------------------------------\n\n"); printf("This student's information is \nname: %s\nsex: %c\nage: %d\nGPA: %lf\n", name, sex, age, gpa); printf("\n------------------------------------------\n\n"); printf("Please press a key for print these values to output file.\n"); getch(); fprintf(outp, "----------------------------------------------\nName: %s\nSex: %c\nAge: %d\nGPA: %0.2lf\n-----------------------------------------------\n\n", name, sex, age, gpa); n++; } while(n<counter); return 0; } |
|
|||
|
Code:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
main()
{
char name[30], sex[2];
int n, counter, age;
double gpa;
FILE *inp, *outp;
inp = fopen("stdlist.txt", "r");
outp = fopen("stdlist.dat", "w");
printf("How many students: ");
scanf("%d", &counter);
n=1;
do
{
printf("Please enter student's name:");
scanf("%s",name);
printf("Please enter student's sex (M or F): ");
scanf("%s", sex);
printf("Please enter student's age: ");
scanf("%d", &age);
printf("Please enter student's GPA: ");
scanf("%lf", &gpa);
system("cls");
printf("\n\n----------------------------------------\n\n");
printf("This student's information is \nname: %s\nsex: %c\nage: %d\nGPA: %lf\n", name, sex, age, gpa);
printf("\n------------------------------------------\n\n");
printf("Please press a key for print these values to output file.\n");
getch();
fprintf(outp, "----------------------------------------------\nName: %s\nSex: %c\nAge: %d\nGPA: %0.2lf\n-----------------------------------------------\n\n", name, sex, age, gpa);
n++;
}
|
|
|||
|
|
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Peculiar UI Problem Needs Tackling | adriyel | C# Programming | 2 | 04-06-2008 08:46 AM |
| Problem read pwd protected Access2K dbase - CR9 & VB6 | mrbar | Visual Basic Programming | 2 | 03-10-2008 05:50 AM |
| How to tackle a programming problem? | TcM | General Programming | 10 | 01-07-2008 12:29 PM |
| i have a problem please help me!!!???? | stack | Java Help | 8 | 09-22-2007 04:17 PM |
| [C] Comparison problem | Alhazred | C and C++ | 1 | 08-29-2007 05:58 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |