Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ChaosCommand

Am I a Bad programmer if I can't remember the majority of functions and code

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

It has been about 4 months since I REALLY started learning programming in c++. I have chekd out the C++ tutorials and Windows tutorials. But I just can''t seem to remember the stuff. I always start a project, but I always have to go back to tutorials or a book to see exactly how to do this stuff. Maybe I am a bad programmer that is just stupid when it comes to code that can''t get it, and should go into another field? Can someone tell me the answer to this: ------------------------------------- int main() { while(1) // While 1, what does it mean? { // HOW DO I BREAK OUT OF THIS // LOOP? If Possible? cout << "All Your Base Belong To Us" << endl; } return 0; }

Share this post


Link to post
Share on other sites
Advertisement
Hi

If I am not wrong, while(1) is an infinite loop, a loop that keeps runnung. If you want to break out of that loop you can put another condition on while, or use break;
O yeah, it is better to write a lot of programs if you want to remember someting. First just copy the code, play with it. And then make a program that differs from the tutorial, but uses the same concepts, without looking at the tutorial.

[edited by - White Crow on August 15, 2003 5:41:22 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by White Crow
Hi

If I am not wrong, while(1) is an infinite loop, a loop that keeps runnung. If you want to break out of that loop you can put another condition on while, or use break;
O yeah, it is better to write a lot of programs if you want to remember someting. First just copy the code, play with it. And then make a program that differs from the tutorial, but uses the same concepts, without looking at the tutorial.

[edited by - White Crow on August 15, 2003 5:41:22 AM]



Thanks, maybe I should be trying to make more programs, but it just gets annoying at the fact that I keep on having to write these tiny text programs, and can''t yet make a game or something that I am proud of yet. I was kinda hoping I would at least be able to program a simple tetris or pong or breakout type clone by now.

I guess only time will tell, with more practice.

Share this post


Link to post
Share on other sites
Don't worry about remembering everything .. try instead to understand *why* things are the way they are .. hopefully you should end up remembering the details by accident.

Also remember that you're using one of the most complex/powerful languages available - it's a steep learning curve but (imo) a rewarding one.

while(1) // While 1, what does it mean?
{ // HOW DO I BREAK OUT OF THIS
// LOOP? If Possible?
cout << "All Your Base Belong To Us" << endl;
}

Breakdown of what's going on here:

while( )
means loop while 'expression' returns true (evaluating expression after each run-through).

In C/C++, anything which isn't 0 is true .. 1 will always be true so the loop will run forever.

The thing 'looped' is the statement or code block which follows the while .. in your case it's everything (code block) within the curly braces:

{
cout << "whatever" << endl;
}

You can break out of an infinite loop using the 'break;' keyword.

while (1) {
cout << "looping!" << endl;
break;
}

Is an 'infinite loop' which will run just once

As a general rule, I would advise against using 'magic numbers' anywhere, even somewhere like while(1) ... it's common practice, but as you're finding, it's not very helpful/readable.

while(true) is what you really mean.

And lastly .. be *very* careful with infinite loops. They can be very annoying to debug. Try either looping for a large, but fixed, number of iterations or putting a hard-coded limits while debugging/testing.

for (int i=0; i<100000; i++) {
}

or

int i=0;
while(true && 100000>i++) {
}

or

int i=0;
while (true) {
if (i>100000) { break; } else { i++; }
}



[edited by - SimbobX on August 15, 2003 8:25:10 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by ChaosCommand
quote:
Original post by White Crow
Hi

If I am not wrong, while(1) is an infinite loop, a loop that keeps runnung. If you want to break out of that loop you can put another condition on while, or use break;
O yeah, it is better to write a lot of programs if you want to remember someting. First just copy the code, play with it. And then make a program that differs from the tutorial, but uses the same concepts, without looking at the tutorial.

[edited by - White Crow on August 15, 2003 5:41:22 AM]



Thanks, maybe I should be trying to make more programs, but it just gets annoying at the fact that I keep on having to write these tiny text programs, and can''t yet make a game or something that I am proud of yet. I was kinda hoping I would at least be able to program a simple tetris or pong or breakout type clone by now.

I guess only time will tell, with more practice.



You''re not the only one man..I know what you mean because i''ve only been doing c++ for a few months myself...Well personally i''m sure that whenever you''re using an API such as DirectX/OpenGL memorizing all the function calls isn''t really that useful simply because there''s plenty of references on them out there. When it comes to language concepts such as pointers, class structures etc it simply takes some time and some practice as you said. I even remember when i had trouble remembering the simple

int main()
{
return 0;
}

lol, but over time, since you understand its purpose and you know why you need it all the time, it sticks in your brain. So i''m sure in the end, what you find most useful from tutorials, books or articles will be what you remember off the top of your head (but trivial code always poke''s around my brain )


no theory`

Share this post


Link to post
Share on other sites
heh i thought it would be so easy to. i''ve been on and off looking at c and c++ for the last 4 years now. I''ve just recently started studying and buckling down and covering all the fields regarding programming since the beginning of summer. If i put my mind to it i could make something now but it would be a hack job of copy paste style code. I''m going to hold off a little while on programming a game and focus on making things such as a notepad for windows or a similar program.


while(1) = infinite loop. the condition is allways true. i like to use these with a "break;" statement. break cuts whatever loop it is in regardless of condition.

Share this post


Link to post
Share on other sites
quote:
Thanks, maybe I should be trying to make more programs, but it just gets annoying at the fact that I keep on having to write these tiny text programs, and can''t yet make a game or something that I am proud of yet. I was kinda hoping I would at least be able to program a simple tetris or pong or breakout type clone by now.


It takes a hell of a long time to learn to program a game, this is simply because it is one of the areas of programming that is so wide reaching and you need to have a lot of skills.

Really the only way to learn is to push youself, take a small text based app and then say to your self, right it randomly selects a sentence from a list, so how can I make it respond to a question i give it by selecting the right sentence as the answer. Never give up on your challenges and you will suceed.

Don''t worry about remembering everything, its soooo easy to forget little things and make a mistake, for example i forgot that doubles are actually just bigger versions of floats and I spent an entire day trying to fix a problem that didn''t exist because of it.

Good luck

You cannot see what does not want to be seen.

Share this post


Link to post
Share on other sites
quote:
Original post by simbobx
one of the most complex


Bah. You''ve not played with INTERCAL.

A computer language, as I see things, is just like any other language; there''s a grammer and a vocabulary (and when it comes to computer languages, I''d say that the grammer also includes language keywords). The vocabulary is usually vast.

So that''s what dictionaries are there for.

Concentrate on learning the important parts of the language - the grammer and keywords - rather than the vocab (or large collection of APIs). I still have MSDN open pretty much whenever I''m coding, and I''ve been doing it for 4 years; I expect I will always have it open, because why try committing it to memory when the information is at your fingertips anyway?

There''s really no problem in not knowing the types of parameters for WinMain() or the sequence of function calls required to draw a bitmap to the screen with GDI. All you have to know is how to find that information when you need it. The web, MSDN, books, a helpful friend... all require good technique for formulating a query.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4

Share this post


Link to post
Share on other sites
Don''t worry, sooner or later you''ll refer to the docs less and less until you can do it all in your head. Trust me, I had to check up EVERYTHING when I first started up but now I practically code DirectX without the docs. It''ll all come by with practice.

---
Brent Gunning | My Site

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!