| | |
weird problem on visual studio
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
hi, i have this simple code, that compiles on visual studio 2005.When i try to run the executable through visual studio {pressign ctrl+F5} it does nothing{although the test.txt has size of 1kb}, when i run the exe through the command prompt the program works fine...
Does anyone know why this is happening??
thanks for your time,
NA
Does anyone know why this is happening??
c++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> using namespace std; int main () { long start,end; ifstream myfile ("test.txt", ios::in|ios::binary); start = myfile.tellg(); myfile.seekg (0, ios::end); end = myfile.tellg(); myfile.close(); cout << "size of " << "test.txt"; cout << " is " << (end-start) << " bytes.\n"; return 0; }
thanks for your time,
NA
VC closes the console window when the program ends. If you want to see the program's output you have to add something before the return to make the program wait for you to press a key before continuing. calling cin.ignore() just before the return statement will accomplish that.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
hi, i have this simple code, that compiles on visual studio 2005.When i try to run the executable through visual studio {pressign ctrl+F5} it does nothing{although the test.txt has size of 1kb}, when i run the exe through the command prompt the program works fine...
Does anyone know why this is happening??
cin.getline() just before the return The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
•
•
•
•
The program opens a window, runs very quickly, finishes, then closes the window. Addcin.getline()just before thereturn
•
•
•
•
VC closes the console window when the program ends. If you want to see the program's output you have to add something before the return to make the program wait for you to press a key before continuing. calling cin.ignore() just before the return statement will accomplish that.
i don't want to read any input...the console window doesn't close....Just the output that appears is wrong...
The program that i posted simply reports the size of file..it doesn't need any interaction from the console....
•
•
•
•
i don't want to read any input...the console window doesn't close....Just the output that appears is wrong...
The program that i posted simply reports the size of file..it doesn't need any interaction from the console....
•
•
•
•
When i try to run the executable through visual studio {pressign ctrl+F5} it does nothing{although the test.txt has size of 1kb}, when i run the exe through the command prompt the program works fine...
Therefore, start over and describe the problem in detail.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- Problem with visual Studio 2003 c# (C#)
- VS.Net compilation problem? (ASP.NET)
- Visual Studio 6.0.. Frozen In Time (C)
Other Threads in the C++ Forum
- Previous Thread: plotting sine curve
- Next Thread: Which library is used for graphics in VC++
Views: 2793 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






