Would you mind helping me to solve the following problem!!

I have a file wires.inp. it is existing in c:\\ctemp\\vuth\\wires.inp. When i tried to open it :

FILE *fwiresInp;
fwiresInp=fopen("c:\\ctemp\\vuth\\wires.inp","r");

Error existed!!! it means that i cannot open the file above. Could u suggest me some solutions??
Is it because of the extension of that file, i mean .inp ??
Otherwise when i changed it to wires.txt, it worked smoothly.

But in this circumstance, i nedd wires.inp not wires.txt.

Thanks in advance

Daravuth KEU- vuthcam

> But in this circumstance, i nedd wires.inp not wires.txt.
What do you think? :icon_rolleyes: Rename wires.txt to wires.inp and your program should work like a charm.

> But in this circumstance, i nedd wires.inp not wires.txt.
What do you think? :icon_rolleyes: Rename wires.txt to wires.inp and your program should work like a charm.

He is already trying to open it with the right file name. FILE FILE *fwiresInp=fopen("C:\\ctemp\\vuth\\wires.inp","r"); Could it be that fopen()is the wrong function to use to understand the format of that file?

He is already trying to open it with the right file name. FILE *fwiresInp; fwiresInp=fopen("c:\\ctemp\\vuth\\wires.inp","r");

That's not what I said. If wires.txt can be opened, obviously it exists. wires.inp can't be opened. So what does that tell you? Either that or the OP's file permissions are seriously screwed up.

[edit]

Could it be that fopen()is the wrong function to use to understand the format of that file?

Or that. If it's binary you'll need "b" added to it.

first i had wires.inp stored in the specific folder then i tried to open it within the :
FILE *fwiresInp;
fwiresInp= fopen("c:\\ctemp\\vuth\wires.inp","r")
. This didn't work.

Second i change my wires.inp to wires.txt then i open it with :
FILE *fwiresInp;
fwiresInp= fopen("c:\\ctemp\\vuth\wires.txt","r")
. This time , it works. Do you guy think that it is coz of the extension??
when creating file in c , extension depends on us , doesn't it??

"r" or "rb" both didn't work in the first test..

regards

vuthcam

first i had wires.inp stored in the specific folder then i tried to open it within the :
FILE *fwiresInp;
fwiresInp= fopen("c:\\ctemp\\vuth\wires.inp","r")
. This didn't work.

Second i change my wires.inp to wires.txt then i open it with :
FILE *fwiresInp;
fwiresInp= fopen("c:\\ctemp\\vuth\wires.txt","r")
. This time , it works. Do you guy think that it is coz of the extension??
when creating file in c , extension depends on us , doesn't it??

"r" or "rb" both didn't work in the first test..

Just curious. What creates the wires.inp file?. What's the format, binary or just text?.
When you changed to wires.txt and opened it, could you read it?. Did
it have meaningful data that you could see like in notepad?.

Another thing, Windows hides the file extensions on known types. The actual name of the file could be wires.inp.txt, but you just aren't seeing it. You can disable this "feature" by opening up Folder Options from Windows Explorer.

It is very kinda of you guy for ur responses!! En ce moment, i have solved that problem i posted above.

My fault is that i right-click -> new -> text file. But then i use the name wires.inp which makes windows doesn't know whether it is .txt file or .inp file. So when i open it in C language, it neither know that file.

This is an experience and actually a tip which we should avoid and be careful.

regards

Daravuth-VuthCam

IMAO, everyone (and I mean everyone!!!) should follow Joe's advice. I don't know why MicroSludge like to hide important information from the user, but it's a well know fact that this feature is used to launch viruses and other nasty things. Not to mention if you have 5 files with the same name but different extensions, how do you know which one you need?

Tools -> Folder Options -> View tab -> uncheck HIDE EXTENSIONS...

Be a part of the DaniWeb community

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