Sign in to follow this  

dose the file stream no longer work in vc2005

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have vc 2005 with windows sdk and i can't access file with ifstream no matter how i do it!! The program compils just fine but the files just can't be opened iv done even the simplist read functions but it wont open so i know it is not my code :( iv tryed restarting to see if mabey the file was being use and wasn't closing but still eval anyone know what microsofts bug is here all there programs worked with vc6

Share this post


Link to post
Share on other sites
Quote:
Original post by Red_falcon
Try use fopen,fwrite,fread
As it turns out, this is precisely what you shouldn't do.

Anyway, can we actually see your code? That it worked with vc6 is a good indicator that your code is wrong.

Share this post


Link to post
Share on other sites
yes so i did try fopen from stuio.h file access varables like so this should work
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ("myfile.txt","wt");
if (pFile!=NULL)
{
fputs ("fopen example",pFile);
fclose (pFile);
}
return 0;
}
But no it says when i compile warrning the fopen has been depresated oh well there right well it tells me my file is invalade but it is in the same folder propper name wtf is wrong with microsoft these days they use to make top dollor compilers

Share this post


Link to post
Share on other sites
iv use code from all kinds of differnt sources but fine here is one that wont work
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
ifstream infile;

infile.open ("test.txt", ios::in);

while (infile.good())
cout << (char) infile.get();

infile.close();
}

Share this post


Link to post
Share on other sites
like i said, i use fopen and so on for my tga loader. the code was written under vs2001, then ported to 2003 and now i work with 2005. That its deprecated is not so bad. But it works

Share this post


Link to post
Share on other sites
Are you sure the file exists in the same directory as the EXE file?

I'll try your code in my VS2005 in a second.

Through their run in the IDE it will look in the project's directory name rather than where the EXE is. So it will be solution then project then Debug or Release. The EXE seems to be put in the debug of the solutions directory.

I wonder if C# for 2005 is different than my 2003...

Share this post


Link to post
Share on other sites
WTF!!!!!!!!!!!@ I just tested it again by pressing the file a buch and i found the problem i hate microsft!!!!!!!!
there comment promt taht comes with vs 2005 is bogus thats right works fine with windows commend promt but not with there vs command promt

Share this post


Link to post
Share on other sites
Quote:
Original post by alex_dergian
WTF!!!!!!!!!!!@ I just tested it again by pressing the file a buch and i found the problem i hate microsft!!!!!!!!
there comment promt taht comes with vs 2005 is bogus thats right works fine with windows commend promt but not with there vs command promt
Your file that you're trying to open is probably in the wrong directory.

Share this post


Link to post
Share on other sites
Quote:
Original post by alex_dergian
WTF!!!!!!!!!!!@ I just tested it again by pressing the file a buch and i found the problem i hate microsft!!!!!!!!
there comment promt taht comes with vs 2005 is bogus thats right works fine with windows commend promt but not with there vs command promt


I pity the fool who doesn't learn his tool.

(hint: check what your current working directory is set to for debug sessions in your project settings)

Share this post


Link to post
Share on other sites

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this