• ### Popular Now

• 10
• 12
• 12
• 14
• 15

This topic is 4673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm seeking advice, almost a "what next?" type of thing. I'm at the point with C++ where I would consider myself above beginner, but below intermediate, somewhere in between. I understand functions, arrays, and essentially most of the basics. However, my problem is that when I go to start a new project, I go blank. I sit there and stare at the screen and think, "How do I accomplish that?" Even something as simple as a guessing game makes me go blank. So, I ask for advice. In your opinion, how could I fix this problem? I started learning C++ when I was about 12, however I off and on studied it for several years. I used tutorials and have a book titled, "Fundamentals of C++ Understanding Programming and Problem Solving." Though, I don't like the book much, it jumps around too much. Anyways, with that background information, I ask again, what would you say I should do?

##### Share on other sites
Practice. [smile]

##### Share on other sites
Thats the problem. I try and think of something to do to practice, and then I go blank. (That's if I can think of something to do, as well.) Whenever I do think of something to try and make, it's usually beyond my boundries.

##### Share on other sites
well, you say you consider yourself "above beginner". i'll guess that means you know how to use loops, if statements, and things of that level. you talked about a guessing game. so sit down, and think about what happens when you ask a person to guess a number, or when they ask you too. and then code the computer to follow those steps. programming is figuring out how to do something, and then coding it. anyone can know what commands do what, but it takes a programmer to figure out how to make those commands, while worthless in and of themselves, to come together and make a whole far greater then their sum. that is what being a programmer is. so work on that imo. if you need help, we're here to help you :).

[Edited by - CJWR on July 9, 2005 3:54:06 PM]

##### Share on other sites
If you find something that should be easy to be difficult, it usually indicates a lack of understanding somewhere. The fact that you do not enjoy reading your beginners book might be the problem. Perhaps buy a different book? Accelerated C++ is highly recommended.

Other than that, you need to start small and work up. If you know how to get input from the user and write out to the user, you are half way there.

#include<ostream>#include<iostream>void PrintWelcomeMessage(){std::cout << "Welcome to the guessing game, please guess a number" << std::endl;}int main(){PrintWelcomeMessage();}

Thats a start, now you want to get some input from the user.

#include<ostream>#include<iostream>void PrintWelcomeMessage(){  std::cout << "Welcome to the guessing game, please guess a number" << std::endl;}int RequestGuessFromUser(){  int UsersGuess;  std::cout << "Please Enter your guess" << std::endl;  std::cin >> UsersGuess;  return UsersGuess;}int main(){PrintWelcomeMessage();int UsersGuess = RequestGuessFromUser();}

Now you have the initial guess, you can do something with it.

#include<ostream>#include<iostream>void PrintWelcomeMessage(){  std::cout << "Welcome to the guessing game, please guess a number" << std::endl;}void PrintWinningMessage(){  std::cout << "You guessed correctly!!" << std::endl;}void PrintLosingMessage(){  std::cout << "You guessed incorrectly!!" << std::endl;}int RequestGuessFromUser(){  int UsersGuess;  std::cout << "Please Enter your guess" << std::endl;  std::cin >> UsersGuess;  return UsersGuess;}int main(){  PrintWelcomeMessage();  int NumberToGuess = 1;  int UsersGuess = RequestGuessFromUser();  if(UsersGuess == NumberToGuess)  {    PrintWinningMessage();  }  else  {    PrintLosingMessage();  }}

Thats a small simple game. You can random it up a bit by using the rand function (with the help of srand) to initialize NumbertoGuess, and the modulus operator to constrain it a bit.

#include<ostream>#include<iostream>#include<cstdlib>#include<ctime>void PrintWelcomeMessage(){  std::cout << "Welcome to the guessing game, please guess a number" << std::endl;}void PrintWinningMessage(){  std::cout << "You guessed correctly!!" << std::endl;}void PrintLosingMessage(int CorrectNumber){  std::cout << "You guessed incorrectly!! The correct number was: " << CorrectNumber << std::endl;}int RequestGuessFromUser(){  int UsersGuess;  std::cout << "Please Enter your guess" << std::endl;  std::cin >> UsersGuess;  return UsersGuess;}void RandomizeTheNumberGenerator(){      std::srand(static_cast<unsigned int>(std::time(0)));}int main(){  PrintWelcomeMessage();  RandomizeTheNumberGenerator();  int NumberToGuess = std::rand()%10;  int UsersGuess = RequestGuessFromUser();  if(UsersGuess == NumberToGuess)  {    PrintWinningMessage();  }  else  {    PrintLosingMessage(NumberToGuess);  }}

Perhaps that helps a little. [smile]

##### Share on other sites
It sounds like what you need is to develop a good "intuition" of how programming works. All those books like Effective C++ and all will tell you how to structure your code, how to make it more efficient, ensure portability, and all kinds of concerns... but there aren't many books that teach you how to *program*. It's like a dark art that we all pick up intuitively somewhere along our journey :)

If you're struggling right now, it's not such a big deal, this stuff comes with experience... I remember when I started out, I saw a demo of a scrolling 2D starfield and I was like, "wow, how did he do that?!!" but now it's embarrassingly easy.

So... if I were you, then I'd just continue doing what you're doing and eventually it will "click"... However, if you really feel like it's too much to absorb, then there is another option. Perhaps you can go to a language like QBasic or Visual basic (I'd say QB is easier because there's no GUI you have to design). BASIC is nice for beginners to develop their intuition because the syntax is so easy.. it's like having a personal robot who you can give commands to in plain English and he'll do them :)

Hope that helps, good luck!

roos