The main problem is that I cannot clear the buffer or cache or whatever you
call it.
I am using version 4.9.9.2
I change the code (cout etc) and it keeps regenerating the old code
If I run another program and make changes, it will work
if I change the program I am having problems with, even to the point of
inserting completely new code (not even related to the prior code) it will not
accept it. I mean I completely erased all the prior code.
I was able to find the exe file after making the changes (compiling etc) and
I did see the changes, but if I compile/run the old stuff is still there.
I did Rebuild All with no effect
I am using this code to keep the console window open:: *with the <limits>
header </limits>
The obvious conclusion is that the code you are modifying is not the code you
are compiling. If you are using a project, the code that gets compiles will be
the code added to the project, not the file you happen to have open.
Check the compile log after the "Rebuild All" (which you should have posted),
it will show you exactly what is being compiled.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The main problem is that I cannot clear the buffer or cache or whatever you
call it.
I don't call it anything; because in the context of your question, it does not
exist. You have observed the symptoms and formulated a false hypothesis to
explain them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clear the input stream by using ignore. I have never used that func. Well if
thats your intention, would you not :
1. cin.getline or cin >> myvar (cin.get will only get one char/number)
2.test input stream with something like "if(cin.good() )" or "if(cin.bad() )"
or whatever
optional 3. cin.clear only if bad of course (this only clears the input flag
by the way)
4. flush cin by dumping rest of input into a string with "cin >> mystringvar" (this will flush the istream::cin buffer)
note: you can flush an ostream, but not an istream; see set four above.
I could be way of, but I would think you are working with some files. You
might want to re-read your info on working with fstreams. They may have better
functions for what you what to do than the standard iostreams functions.
As for pausing the console:
1. char * pauseoutput = "pause...";
2. char pauseinput;
now you can just insert anywhere you what a pause like:
my code
cout << pauseoutput;
cin >> pauseinput;
continue my code (or exit program)
You will have to hit a key and return of course to continue program execution.
For a delay you could use a simple for or while loop to do nothing, if thats
your intention.
As for the funny compile, you could have a bad spot on your disk or whatever
you use to store the file. The file itself may some how be corrupt. One bit is
all it takes like an attribute bit for example. Try running a scan disk
program and checking your file properties. If that fails rename the file
badfile.xxx and start over.
You will have to teach me how to read the *.exe file. The only place I've seen
that was in the movie "The Matrix". You are truly unique and inhuman. I mean
that as a complement of course.
Good luck and happy programing
PS buy a C++ book, any C++ book
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Compiler: Default compiler
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\Owner\Documents\Dev Cpp programs\PROGRAM FOR MATT
revised.cpp" -o "C:\Users\Owner\Documents\Dev Cpp programs\PROGRAM FOR MATT
revised.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-
Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C
:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
Execution terminated
Compilation successful
You will have to teach me how to read the *.exe file. The only place I've
seen that was in the movie "The Matrix". You are truly unique and inhuman. I
mean that as a complement of course.
I do feel inhuman :) No not read the exe file, run the exe file. I can make
changes to the code and when compile/run no changes in the console window.
However if I search for the file in my computer, I hit the exe file and then I
see the changes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is almost certain that your problem stems from using a project path that
contains spaces. There are known bugs in Dev-C++ itself and the make utility
that mean that under some circumstances, spaces in paths will cause problems.
In this case since you can directly execute the executable and have it work,
it is obvious therefore that the executable that is being run from Dev-C++ is
not the same executable that is being generated by Dev-C++. You can tell
Dev-C++ explicitly where to find the executable in the project options, but
you will be better off fixing the root cause and moving the project to a path
without spaces.
The issue with spaces in paths is clearly mentioned in the "PLEASE READ
BEFORE POSTING A QUESTION" thread (as is the need to post the Compile Log;
which would have saved a lot of time had you done so in the first instance).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi,
It is almost certain that your problem stems from using a project path that
contains spaces. There are known bugs in Dev-C++ itself and the make utility
that mean that under some circumstances, spaces in paths will cause problems.
I think my compiler is possessed :)
The main problem is that I cannot clear the buffer or cache or whatever you
call it.
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cin.get(); </std::streamsize>
out.close();
return 0;
}
Thanks to all replies!!!!
The obvious conclusion is that the code you are modifying is not the code you
are compiling. If you are using a project, the code that gets compiles will be
the code added to the project, not the file you happen to have open.
Check the compile log after the "Rebuild All" (which you should have posted),
it will show you exactly what is being compiled.
I don't call it anything; because in the context of your question, it does not
exist. You have observed the symptoms and formulated a false hypothesis to
explain them.
Clear the input stream by using ignore. I have never used that func. Well if
thats your intention, would you not :
1. cin.getline or cin >> myvar (cin.get will only get one char/number)
2.test input stream with something like "if(cin.good() )" or "if(cin.bad() )"
or whatever
optional 3. cin.clear only if bad of course (this only clears the input flag
by the way)
4. flush cin by dumping rest of input into a string with "cin >> mystringvar" (this will flush the istream::cin buffer)
note: you can flush an ostream, but not an istream; see set four above.
I could be way of, but I would think you are working with some files. You
might want to re-read your info on working with fstreams. They may have better
functions for what you what to do than the standard iostreams functions.
As for pausing the console:
1. char * pauseoutput = "pause...";
2. char pauseinput;
now you can just insert anywhere you what a pause like:
my code
cout << pauseoutput;
cin >> pauseinput;
continue my code (or exit program)
You will have to hit a key and return of course to continue program execution.
For a delay you could use a simple for or while loop to do nothing, if thats
your intention.
As for the funny compile, you could have a bad spot on your disk or whatever
you use to store the file. The file itself may some how be corrupt. One bit is
all it takes like an attribute bit for example. Try running a scan disk
program and checking your file properties. If that fails rename the file
badfile.xxx and start over.
You will have to teach me how to read the *.exe file. The only place I've seen
that was in the movie "The Matrix". You are truly unique and inhuman. I mean
that as a complement of course.
Good luck and happy programing
PS buy a C++ book, any C++ book
Log following the rebuild:
Compiler: Default compiler
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Users\Owner\Documents\Dev Cpp programs\PROGRAM FOR MATT
revised.cpp" -o "C:\Users\Owner\Documents\Dev Cpp programs\PROGRAM FOR MATT
revised.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-
Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C
:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
Execution terminated
Compilation successful
I do feel inhuman :) No not read the exe file, run the exe file. I can make
changes to the code and when compile/run no changes in the console window.
However if I search for the file in my computer, I hit the exe file and then I
see the changes.
It is almost certain that your problem stems from using a project path that
contains spaces. There are known bugs in Dev-C++ itself and the make utility
that mean that under some circumstances, spaces in paths will cause problems.
In this case since you can directly execute the executable and have it work,
it is obvious therefore that the executable that is being run from Dev-C++ is
not the same executable that is being generated by Dev-C++. You can tell
Dev-C++ explicitly where to find the executable in the project options, but
you will be better off fixing the root cause and moving the project to a path
without spaces.
The issue with spaces in paths is clearly mentioned in the "PLEASE READ
BEFORE POSTING A QUESTION" thread (as is the need to post the Compile Log;
which would have saved a lot of time had you done so in the first instance).
cpns: Thank you again for your guidance!
hi,
It is almost certain that your problem stems from using a project path that
contains spaces. There are known bugs in Dev-C++ itself and the make utility
that mean that under some circumstances, spaces in paths will cause problems.
regards,
phe9oxis,
http://www.guidebuddha.com