R
Raj
Following is a code to open a file & print its contents on screen. But
im getting the message "file can't be opened". The thing is, that if i
create a file separately in a particular folder in C drive, only then
my file programs are working, i.e. even after providing the full path
name for the location of the file whose contents i want to read, if
the file is not present in the above specified folder, im still not
able to open the file. This particular file also resides in C drive,
but not in the folder i mentioned above.. This same code works fine
for any file in that folder and that folder only.... So my question
is, how can i read a file that resides in a different folder??
Code:
#include<stdio.h>
int main(void)
{
FILE *f;
char ch;
clrscr();
f=fopen("C:\manni\PLACE4.C","r");
if(f==NULL){
printf("File can't be opened");
getch();
exit(1);
}
while(!feof(f)){
ch=fgetc(f);
printf("%c",ch);
}
fclose(f);
getch();
return 0;
}
im getting the message "file can't be opened". The thing is, that if i
create a file separately in a particular folder in C drive, only then
my file programs are working, i.e. even after providing the full path
name for the location of the file whose contents i want to read, if
the file is not present in the above specified folder, im still not
able to open the file. This particular file also resides in C drive,
but not in the folder i mentioned above.. This same code works fine
for any file in that folder and that folder only.... So my question
is, how can i read a file that resides in a different folder??
Code:
#include<stdio.h>
int main(void)
{
FILE *f;
char ch;
clrscr();
f=fopen("C:\manni\PLACE4.C","r");
if(f==NULL){
printf("File can't be opened");
getch();
exit(1);
}
while(!feof(f)){
ch=fgetc(f);
printf("%c",ch);
}
fclose(f);
getch();
return 0;
}