i want the user to enter a path to save or open a file but i dont know how to do that .. here i just declared another variable named "path" and then palce it in the program ..but no luck ....
well can you help me find out the problem and correct it
i really appreciate your help
thank you
here is the program
//In the name of GOD
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <process.h>
#include <dos.h>
#include <stdlib.h>
#include <fstream.h>
#include <string.h>
FILE *fptr;
struct students{
char name[36];// students names goes here!
float grade;// students grades goes here too!
int classnum;//students class number goes here !
//Total memory accupied by these varibles is 26+6+2=44
}st;
main(){
int i;
char path[80];
clrscr();
fptr=fopen(path,"w");//There is a document which i want to write data in it.
if (fptr==NULL) { printf("Error: failed to open file\n"); exit(0); }
filebuf(25); //Buffer is Set as to have the same size of acupied memory in order to save the data continuesly.
gotoxy(25,5);
cprintf("In the name of god");
gotoxy(18,7);
cprintf(" A Master Project");
gotoxy(10,9);
printf("Please Enter your path ");
scanf("%s",path);
gotoxy(15,12);
cprintf(" Please Enter the students name,grade and classnumber");
for (i=0;i<=1;i++){
scanf("%s",st.name);
scanf("%f",&st.grade);
scanf("%d",&st.classnum);
fwrite(&st,sizeof(st),1,fptr);}
fclose(fptr);
return 0;
}


Sign In
Create Account


Back to top









