int main(int argc, char *argv[])
{   ifstream inHandle;
    Assembler obj;
    if(argc!=2)
    {	cout<<"InvalidInput ERROR";
    }
    else
    {   inHandle.open("test.asm");
	if(inHandle==0)
             cout<<"FileNotFound ERROR";
	else
	     obj.pass1(inHandle);
    }
    inHandle.close();
    return 0;
}

this is my code for the main() function, i have tried entering the filename in every possible format but the control always jumps to..

if(inHandle==0)
    cout<<"FileNotFound ERROR";

..Can anyone please suggest me what the problem could be?!?

NOTE: i am using TurboC++ v3.0

Recommended Answers

All 8 Replies

try using if( inHandle.is_open() ) The problem might also be that the file does not exist in the current working directory.

try using if( inHandle.is_open() ) The problem might also be that the file does not exist in the current working directory.

[IMG]http://img841.imageshack.us/img841/3268/tempih.th.jpg[/IMG]


* i have tried specifying the complete path at command line
* i have placed the file not just in the right directory but practically every directory

..so its gotta be something else. please HELP me here.

Try using perror to see if you can get a more informative error message.

Do you have the permissions to read the file/directory ?

Do you have the permissions to read the file/directory ?

Ofcourse is do, im logged in as Administrator.

bump ^^

and comments or suggestion would be incredibly helpful..

try the same program with a more modern compiler, such as Code::Blocks or VC++ 2010 Express, both free. The problem might be that old compiler you are trying to use on MS-Windows operating system.

bump ^^

Bumping is extremely rude. You're not important enough to justify pushing everyone else down, and one person to page 2.

and comments or suggestion would be incredibly helpful..

Did you try my suggestion? Because if not, I'm not going to help any further. You can get a reasonably informative error message with perror because 9 times out of 10, the iostreams library will correctly set errno.

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.