+1  A: 

Your assumption is wrong about extensions. If fopen is returning NULL, you should output the result of strerror(errno) or use the perror() function to see why it failed.

Edit: The problem is probably because you have "c:\tc\bin\hi.ttcn". in C, "\t" is interpreted as tab, for example.

You could do

"c:\\tc\\bin\\hi.ttcn"

But this is extremely ugly, and your system should accept:

"c:/tc/bin/hi.ttcn"
Chris Young
+1  A: 

The most likely culprit is your Turbo C, an ancient compiler. It's techincally a DOS compiler, not Windows. That would limit it's RunTme Library to 8.3 filenames. Upgrade to something newer - Turbo C++ seems like a logical successor, but Microsoft's VC++ Express would work as well.

MSalters
If the 8.3 filename limitation is the problem, you can open a Command Prompt window and use the command DIR /X to show the "short name" version of your .ttcn file. (For compatibility reasons, Windows allows any non 8.3-format filename to *also* be referenced by an 8.3-format filename.)
j_random_hacker
ya I know that but I tried to know the solution for this scenario.
Manoj Doubts
OkThank you Mr. j_random_hacker for teaching me this.I got the answer by your comment. You gave me real answer what is needed but in a comment. If you have given that as an answer I would have voted you and accepted as correct answer. Thank you once again.
Manoj Doubts
You're welcome Manoj :)
j_random_hacker
A: 

Now that you've posted the code, another problem comes to light.

The following line:

fp=fopen("c:\tc\bin\hi.ttcn","r");

Should instead read:

fp=fopen("c:\\tc\\bin\\hi.ttcn","r");

In C strings, the backslash (\) is an escape character that is used to encode special characters (e.g. \n represents a newline character, \t a tab character). To actually use a literal backslash, you need to double it. As it stands, the compiler is actually trying to open a file named "C:<tab>c<backspace>in\hi.ttcn" -- needless to say, no such file exists!

j_random_hacker
okok I was such a fool I edited my code for better understanding by replacing argv[1] with the file path but I didn't thought of this one while pasting it here. Thanks
Manoj Doubts
Relax, we've all made this mistake at least once... :)
j_random_hacker
+1  A: 

MS-DOS does not know about long file names, thos including files with extensions longer than 3 characters. Therefore, the CRT provided by Turbo C most probably does not look for the name you are providing, but a truncated one - or something else.

Windows conveniently provides a short (i.e. matching the 8.3 format, most of the time ending in ~1 unless you play with files having the same 8-character prefix) file name for those; one way to discover it is to open a console window and to run "dir /x" in the folder your file is stored.

Find the short name associated to your file and patch it into your C source file.

Edit: Darn, I'll read the comments next time. All credits to j_random_hacker.

RaphaelSP
Dont feel ... you have done a good job thank you
Manoj Doubts