-
Problems w/ Dev C++
I wasn't really sure where to put this. It's my first post on this board, and it might not be the last. :)
But anyways, I've been having trouble with that free compiler Dev C++ and I was wondering if anyone could help me.
I wrote a console based program that stored contacts (as in, people's address and phone number etc..) using classes and vectors. I didn't finish writing it, (minus a few list functions, and all the saving/loading) but I tied off all the loose ends and got it to compile. (Almost. At first I had to send it to a friend using gcc to compile and then send the program back to me just to proove to me it wasn't the code)
When it finally ran, nothing happened except I noticed it sitting around in the processes (I'm using XP sadly) taking up space, so I killed it. I figured since I had a prompt that it would at least stop there, and if somehow my program hadn't even made it that far, I decided to put a system("PAUSE"); in at the very beginning to see if it got that far, and it did. So I took that one out, and put one in a little after some output and other commands should've finished, but it only displayed the system("PAUSE");. This is boggling my mind, and no one else has been able to help me with this problem. If it persists, I'll uninstall DevC++ but I'd prefer not to.
Any help would be appreciated.
-
My guess is that your code isn't doing what you think it is. Post it. :)
-
your answer: it's not Dev-C++'s fault.
give us some code and we'll show you where you went wrong. maybe you're right and you need to reinstall Dev-C++, because that has happened before, but it's usually not the case. especially when you're still using system("PAUSE"); to test your program...
-
-
Here's the code.
I uninstalled DevCpp and reinstalled. Same problem. Maybe it is the code. Now hoever, there's one error that won't even let it compile that I can't figure out. (Jeeze this is a wreck huh?) It says:
2
C:\Documents and Settings\Start\My Documents\Eli\C++\Projects\CM\2
unable to run program file.
It used to compile, and only do system("PAUSE");, now it just doesn't compile. I don't know how much you guys wanna see so.... O.o here's everything I have done, and thanks for your time:
Code:
//Just so you all know, this isn't meant to work correctly yet.
//but this SHOULD compile. Anyways, I'm a beginner, so any help would be
//much appreciated.
#include <iostream>
#include <vector>
#include <fstream>
#include <strings>
using namespace std;
class contact{
public:
contact(string* name){
firstName=*name;
}
protected:
string firstName;
};
class list{
public:
list(string* name){
listName=name
}
void nCont();{
return;
}
void eCont();{
return;
}
void vCont();{
return;
}
void dCont();{
return;
}
protected:
string listName;
vector<contact> contactList;
};
void cList(); // Create list
void lList(); // Load list
void vList(); // View list
void sList(); // Save list
void dList(); // Delete list
char debug; // For debugging
int main(){
cout << "DEBUG: Start of program..." << endl;
cin >> debug; // This doesn't work?
cout << "Contact Manager..." << endl;
cout << "Input 'h' for help." << endl << endl;
system("PAUSE"); // But this does!
list none;
none.setBlank();
cLine(&none); // Enter commands, pass a blank list
return 0;
}
void cLine(list *noList){
char cBuff; // Input buffer
list *loaded=noList;
do{
cout << ">";cin >> cBuff; /*Read command*/ cout << "\n";
switch (cBuff){ // Evaluate command
case 'h':
case 'H': // Show help
showHelp();
break;
case 'q':
case 'Q': // Quit after confirm, if no, prompt
cout << "\n"
<< "You have chosen to quit. Any unsaved information will"
<< "be lost.\nAre you sure? [y/n]: ";
cin >> cBuff;
if (cBuff=='y'||cBuff=='Y'){ // Only 'y'||'Y' terminates
return;
}
else{ // Anything else aborts termination
cout << "\n"
<< "Quitting aborted...\n";
}
break;
case 'c':
case 'C':
cList();
break;
case 'l':
case 'L':
lList();
break;
case 'i':
case 'I':
vList();
break;
case 's':
case 'S':
sList();
break;
case 'd':
case 'D':
dList();
break;
case 'n': /* There's a better way to do all of these using a member function that */
case 'N': /* checks to see if the loaded list is blank, but I'll use this for now. */
if (loaded->blank==true){
cout << "Please [l]oad a list first.\n";
}
else{
loaded->nCont();
}
break;
case 'e':
case 'E':
if (loaded->blank==true){
cout << "Please [l]oad a list first.\n";
}
else{
loaded->eCont();
}
break;
case 'v':
case 'V':
if (loaded->blank==true){
cout << "Please [l]oad a list first.\n";
}
else{
loaded->vCont();
}
break;
case 't':
case 'T':
if (loaded->blank==true){
cout << "Please [l]oad a list first.\n";
}
else{
loaded->dCont();
}
break;
default:
cout << "Illeagal command. Input 'h' to display help.\n";
break;
}
}
while(true);
return;
}
void showHelp(){ // Display help
cout << "\n"
<< "Issue a command by inputting the coresposnding\n"
<< "letter in brackets.\n"
<< "\n"
<< "[H]elp\n"
<< "[Q]uit\n"
<< "[C]reate New Contact List\n"
<< "[L]oad Contact List\n"
<< "V[i]ew Contact List\n"
<< "[S]ave Contact List\n"
<< "[D]elete Contact List\n"
<< "Create [N]ew Contact\n"
<< "[E]dit Contact\n"
<< "[V]iew Contact\n"
<< "Dele[t]e Contact\n"
<< "\n";
return;
}
void cList(){ // Doesn't actually do anything yet.
string name;
cout << "Input name for list: ";
cin >> name;
cout << "List " << name << "created. Remember to save.\n";
return;
}
void lList(){
return;
}
void vList(){
return;
}
void sList(){
return;
}
void dList(){
return;
}
Hope this is what you guys need.
-
Update
I figured if it was the code, I'd just start from scratch and see where it went wrong along the way.
The following code also gave me the same exact compile error as stated above:
Code:
#include <iostream>
using namespace std;
int main(){
char x;
cout << "Hello world!";
cin >> x;
return 0;
}
If I didn't know any better I'd assume it was my code, but after testing a little program like that and getting the same error...
My guess is something got switched around in the preferences or options, and I'm not sure what. (I haven't even touched them this install, so the default settings don't work for me if that's the case.)
If someone can either fix this, or suggest a good IDE/Compiler for beginners, I'd be very greatful.
I used a linux based editor during a programming competition once that I liked, but I forget the name of it.
Thanks a lot.
-
There is an unofficial dev-cpp faq here which I recommend that you read. Pay particular attention to the install/uninstall sections.
-
D'uh
Well, I read the FAQ, and it fixed the problem. Windows XP are teh sux0rz.
I feel like a moron for not looking at the FAQ earlier, but it's OK. At least I can compile my own friggin' programs now.
I feel embarassed to have posted that code, since now that the compiler works, I realize that whole thing is a giant mess. ^^
Oh well. Live and learn. I'll probably just start it over from scratch.
Thanks a lot you guys, especially Ken. ;-)
Wish me luck.
-
>>Oh well. Live and learn
and thats exactly what this board exists for
>>linux based editor during a programming competition
my personal recommendation is Kwrite, and emacs comes in a close second (you need to change the preferences so it colour codes code)