C++

What should I be digressing about?

C++

Postby Korin on Tue May 20, 2008 3:34 pm

So yea I'm trying to make a program involving chapter terms n' a quiz. When I try to run it I get a blank screen, or when I run the .bat nothing shows up. Can anyone help?

Code so far...

// Game Loop for Quiz Program


#include <iostream>
#include <string>

using namespace std;
int main()
{
return 0;
}

void QUIZ(void)
{
int done = false;
int i;
char answer[32];

while (!done)
{
for (i = 0; i < 5; i ++)
{
// Questions to ask
}

// does user want to continue?
printf("Do you want to keep going? (y/n) \n");
scanf("%'s", answer);

if (strcmp("n", answer) == 0)
{
done = true;
}
}
}
class Question
{
public:

// question displayed to the user.
char* questionText;

// The four possible answers.
char* answer0;
char* answer1;
char* answer2;
char* answer3;

int nCorrentAnswer; // number representing which of the answers is corrent
};

// Now create a global variable with a bunch of Question obects, with multiple objects in called an "array". automatically filling them with the questions and answers. Note the commas seperate the questions, so if you add more look out that each question except last is seperated at the end with a comma.

Question questions[2] =
{
{"What is the capital of France?", "England", "Paris", "Nice","F", 1},
{"Which of these begins with A?", "Apple", "Ball", "Car","Door", 0}
};

// Then finally, to get at these in a function or class method:

void Function()
{
// Count from 0, and put the number of the question in the square brackets... like questions[0]

printf(questions[0].questionText); // print the question text of first question to the screen.

}

Help plx? :D
WTF does "WEIGHTED PHRASE LIMIT EXCEEDED" mean?!
Korin
 
Posts: 32
Joined: Fri May 09, 2008 2:29 pm
Location: <Insert Sarcastic Remark Here>

Re: C++

Postby Dave on Tue May 20, 2008 11:49 pm

Uh... James...?
Interested in a Commission? Visit my DeviantArt Gallery (http://latecustomer.deviantart.com/gallery/) and leave me a note there.
User avatar
Dave
 
Posts: 2580
Joined: Fri Feb 08, 2008 5:27 pm
Location: Los Angeles

Re: C++

Postby james on Wed May 21, 2008 6:44 pm

LOL. I was waiting for someone to point at me. Quite honestly... I have not done C++ in so long, that I need to read up even to answer simple things. What is the program supposed to do exactly? The only thing that looks funny to me is that IIRC, in C++ the function needs to be first defined, then called on afterward. I see the functions being created, but not called.

Something like

void Function()
{
// Count from 0, and put the number of the question in the square brackets... like questions[0]

printf(questions[0].questionText); // print the question text of first question to the screen.

}


should be defined at the beginning up around here somewhere

#include <iostream>
#include <string>

using namespace std;
void Function();
int main()
{
return 0;
}


C++ uses a single pass compiler, thus the functions need to be defined before they are used. Is this for a class, or are you just doing it to learn? Most likely I would need to brush up before I can give you a solid, good answer. I would take what I gave you and read into it a little more. I think the last time I did anything in C++ was about 7 years ago... thus I am a little rusty. :shock:
http://www.redlinedaily.com

PETA: People Eating Tasty Animals.
Meat is Murder.... Tasty, Tasty Murder.
User avatar
james
 
Posts: 221
Joined: Thu Feb 07, 2008 10:33 pm
Location: Eagle Rock, CA

Re: C++

Postby Yino on Wed May 21, 2008 7:23 pm

Well I never liked C++, I don't like C either :P. Taking a quick look.
Your main function is not calling anything, and are you sure that the global variable is accesible from those functions?. And from what I recall (at least 2 years ago), creating a class in C++ was much more complex, requiring a header file (.hpp).
Meh, I suggest you to use Python, be happy hehe. :D
<insert signature>
User avatar
Yino
 
Posts: 1133
Joined: Fri Feb 08, 2008 6:08 pm
Location: Somewhere in Chile

Re: C++

Postby james on Thu May 22, 2008 2:29 am

I just hated C++ because of the use of pointers... I hate having so much power to fuck up the memory... Honestly, If I could get someone to pay me for programming, I think I would try a lot harder. I learned a lot about PHP working on the old squishy site, but that don't help in C++.
http://www.redlinedaily.com

PETA: People Eating Tasty Animals.
Meat is Murder.... Tasty, Tasty Murder.
User avatar
james
 
Posts: 221
Joined: Thu Feb 07, 2008 10:33 pm
Location: Eagle Rock, CA

Re: C++

Postby Yino on Thu May 22, 2008 4:56 am

Oh yeah, Memory leaks and zombie processes *sigh* such memories ;). PHP is so much better.
<insert signature>
User avatar
Yino
 
Posts: 1133
Joined: Fri Feb 08, 2008 6:08 pm
Location: Somewhere in Chile

Re: C++

Postby Korin on Thu May 22, 2008 3:00 pm

Fixed and compiled, then ran the program to find a blank screen. When I run the .bat file I get absolutely nothing, aside from the program location.

Gah... Running out of time. This damn quiz program is due next tuesday. But guess what? I'm homeless and have no school tomorrow or monday.

Thinking... Thinking... Already checked the 'net for source codes, found none... Grrr. I'm at a loss as to what I can possibly do, aside from reading over my entire c++ book this weekend and then cramming everything into one doodle.

THIS GRADE DICTATES WHETHER OR NOT I GRADUATE!!!

@_@
WTF does "WEIGHTED PHRASE LIMIT EXCEEDED" mean?!
Korin
 
Posts: 32
Joined: Fri May 09, 2008 2:29 pm
Location: <Insert Sarcastic Remark Here>

Re: C++

Postby Parsifal on Thu May 22, 2008 11:41 pm

Holy carp. If it's that important, you might want to hit up forums dedicated to the topic. It's not that we don't /want/ to help you:(

You can always try http://www.cplusplus.com/, or some other C++ related site. Heck *dodges filter*, if it really comes down to it there's always SourceForge Marketplace where you can place a "bounty" for someone to look over your project and explain/fix what you did wrong. I'd suggest just asking someone you know or giving the textbook another look before that, though.
User avatar
Parsifal
 
Posts: 495
Joined: Wed Feb 13, 2008 8:01 pm
Location: Mobile(phone)

Re: C++

Postby james on Fri May 23, 2008 5:02 pm

Yino wrote:Your main function is not calling anything


Ding Ding Ding Ding!!! We have a winner!

From what I have read, Yino is right. You need to have something in the main function for the program to do anything. There are no syntax errors, so the program will compile without errors. I would check out this website: http://www.devarticles.com/c/a/Cplusplus/Beginners-Guide-to-Functions-in-C-plus/. That is how I figured out about the main thing. Try following the examples on that page. I think it will help a lot.
http://www.redlinedaily.com

PETA: People Eating Tasty Animals.
Meat is Murder.... Tasty, Tasty Murder.
User avatar
james
 
Posts: 221
Joined: Thu Feb 07, 2008 10:33 pm
Location: Eagle Rock, CA


Return to Generalalities and Random Tangents

Who is online

Users browsing this forum: No registered users and 1 guest

Learn about Advertising | Learn about Contributing | Learn about Us

Website is © 2005-2008 Direman Press. All content is © their respective creators. All rights reserved.
cron