hello coders,

I am facing problem to filing my programm. it opens the intended file but problem is it is not saving any datas. I want to see the results in notepad or word. I am using windows vista and my soft is dev C++. I dont want to use <iostream> at this moment, I want to use FILE option instead. Here is my log given below, if anyone has got any idea and can test it in there own computer and can post the result will be highly appreciated.

#include <stdio.h>
FILE *f1;
printf("Data Input\n\n");
f1=fopen("Student marksheet","w");

struct personal
char name[20];
char birthday[12];
int id;
char course [10];
struct personal person;
printf("input values\n");

scanf("%s %s %d %s",&person.name,&person.birthday,&person.id,&person.course);
printf("%s %s %d %s\n",person.name,person.birthday,person.id,person.course);
int n, m, i, j,t,roll_number, marks, total;
float average;
printf("enter number of students and subjects\n");
scanf("%d %d",&n,&m);
printf("Enter roll_number");
printf("\n Enter marks of %d subjects for roll No.%d \n",m,roll_number);

scanf ("%d",&marks);
printf("Total marks=%d",total);
printf("average=%f\n", average);

if (average>=70)
printf("Grade A\n\n");
else if (average>=60)
printf("Grade B \n\n");
else if (average>=50)
printf ("Grade C \n\n");
else if (average>=45)
printf("Grade D\n\n");
else if (average>=40)
printf("Grade E\n\n"); 

printf("\nData Output\n\n");
f1=fopen("Student Marksheet","r");


Recommended Answers

All 2 Replies

You are not trying to save anything to the file, i.e. there are no calls to any function that would write to the file. If you are familiar with printf(), try looking up fprintf() and using it to write to the file.

Last but not least, learn to use the code tags when you post code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.