5
Contributors
9
Replies
33
Views
3 Years
Discussion Span
Last Post by parth2911
0
#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("c:\\1.txt","r+");
return 0;
}

its not working..plz help..

0

How can you tell that program isn't working since it doesn't actually have any output?

Edited by Banfa

1

In order to know if it worked or not you have to test the return value of fopen()

#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("c:\\1.txt","r+");
if( fp == NULL)
   printf("file not found\n");
else
   printf("Success!\n");
fclose(fp);   
return 0;
}
-1

using this code its only print success..
i want to display file in notepad..

0

using this code its only print success..

That's the point of the program, to tell you whether the file was opened successfully.

i want to display file in notepad..

Please note that we're not going to write your program for you. You asked a specific question and got a specific answer. Now it's up to you to ask more specific questions or apply what you've learned in this thread to your actual program.

1

You asked the wrong question at the beginning of this thread. Why didn't you say that in the first place, we can't read your mind. You need to use this function to launch Notepad.exe

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.