C++ Where to start. what to do?

Samael88

Evil always finds a way
Reaction score
181
i dont want to make games persay, i may want to do that. but i want to step into it. I want to make some simple programs first. For example. A word scrambler. that takes the first and last letter of a word, and randomly scrambles all of the letters in-between

That c++ is great for. The thing about c++ is that it does not have many limitations, you don't need to learn everything about it to make a simple program as that.
There is actually enought information on those tutorialpages I mentioned earlier to do just that.

Python is best for making lightweight applications and it has an easy syntax, I personally wouldn't use it for making 3D applications.

Dude, python is a descent language, but c++ is better to learn from the beginning and that's it.
3D apps are no problem at all with python btw, the code tends to be a bit messy tho, "mount and blade" is a 3D game written in python and it runs smooth and well, there is even HD addons for it that works just fine.

If we compare the two examples you used earlier, what do you learn about programming from this "print Hello World!"?
1. That python is simple.
2. How to print text with python.

What do you learn from this:
Code:
#include <iostream>
using namespace std;
void main()
{
  cout << "Hello World!" << endl;
}

1. How to use headers.
2. Writing a simple function.
3. Using namespaces.
4. Displaying text.
5. How to jump to the next line to write.

That is why I personally think that c++ is better for beginners, python is just to easy for a beginner to actually learn something about programming from it.
 

ElderKingpin

Post in the anime section, or die.
Reaction score
134
i think making the word scrambler is harder then you think. My dad told me you would first have to make an array variable for the letters so the variable could have more then one variable. And have the first letter to be [loc 1] and the last letter to be [loc 7] (i used the word "Macbook") and have the system scramble location 2-6. Then you would need more variables to handle more words (handling more words was my idea btw, i thought of that through common sense
 

Vestras

Retired
Reaction score
248
VS2010 comes with a new MFC package that enables you to create Office 2007/Visual Studio like applications in no time. (Actually they're templates)

MFC makes C++ code much more readable, and then it actually looks good compared to Win32 native bullshit.
 
Reaction score
333
That c++ is great for. The thing about c++ is that it does not have many limitations, you don't need to learn everything about it to make a simple program as that.

Well your example below shows that you do need to understand several parts of C++ in order to write a simple program.

Dude, python is a descent language, but c++ is better to learn from the beginning and that's it.

There are few good reasons to believe that this is the case, and many good reasons to believe that it isn't.

What do you learn from this:
...

You don't learn anything from that. It's the explanation that comes with the code that you learn from. A new programmer would probably be able to deduce that "cout" has something to do with "Hello World!" appearing on the screen, but little beyond that.

The hello world program you provided, by the way, is incorrect.

That is why I personally think that c++ is better for beginners, python is just to easy for a beginner to actually learn something about programming from it.

If you are learning Python (or Ruby, or C++, etc), then you are learning the fundamentals of programming. C++ might require boilerplate for the simplest programs, but that doesn't mean that it is better for learning.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Python 3D is easy but since Python is interpreted it's going to be slower when you're making hundreds of large calculations each second.

For 3D I'd go with D, but before D came out I would've gone with C++.

______

On another note to make a word scrambler in python you'd just need to use yourstrvar.count(sub[, start[, end]])

http://docs.python.org/library/stdtypes.html
 

Samael88

Evil always finds a way
Reaction score
181
@Damien: The code I provided was quoted from codemonkeys earlier post, so don't tell me that I wrote wrong;)


On another note to make a word scrambler in python you'd just need to use yourstrvar.count(sub[, start[, end]])

http://docs.python.org/library/stdtypes.html

With this quote I will stand by my belief that python is taking the easy way out.
You would learn more by doing it in c++. You would probably gain a few headaches and run into a few walls, but in the end you will have learned more from it than you would using python. Since each time you run into a problem you will be forced to think or look something up in a tutorial and hopefully learn something new each time.

@ElderKingpin: That wordscrambler thought you had there, you are on the right track, if you want it to be a simple program where you give it input manually it is quite easy to do. If you on the other hand want it to get info from a file and output it into another file, that will get a bit more complicated.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
It's true Python is easy to use, that's why it's a high level programming language. You have all the functionality of C++ too, the main reason people would use C++ over Python is because C++ is faster.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
C++ came out in 1983, Python came out in 1991. Both are old in retrospect.
 

Slapshot136

Divide et impera
Reaction score
471
can we just stop the python vs c++ discussion here? the OP asked for C++ specifically, not "what is the best programming language to learn"

also for a c++ program to scramble a word you dont need a char array, a string is pretty much already that, but either way it's not too hard, i would do it like this:


Code:
#include <iostream>
#include <string>

using namespace std;

string scramble(string);

int main()
{
	string word = "Macbook";
	word = scramble(word);
	cout << word << endl;
}


string scramble(string wordToScramble)
{
	int length = wordToScramble.length();
	string scrambled;
	for (int i = 0; i < 10; i++)
	{
		scrambled = "";
			for (int i = 0; i < length; i++)
		{
			if (rand() % 2)
				scrambled += wordToScramble[i];
			else
				scrambled = wordToScramble[i] + scrambled;
		 
		}
		wordToScramble = scrambled;
	}
	
	return scrambled;

}


and no, I dont want to see how simpler the python version, TYVM.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
I'm pretty sure the entire point was to let him figure out how to make it, and show what he might need to use.
 

Samael88

Evil always finds a way
Reaction score
181
I'm pretty sure the entire point was to let him figure out how to make it, and show what he might need to use.

That was what I was trying to do.
Slapshot, you just gave him a fish:p

Oh, and you could have just written the function above the main instead of using the "dummy line":eek: It scrambles the whole word, and if you have the main as an int you would need a return in it;) And you don't have anything that pauses the program, it will just blink up and then go down again.
"if (rand() % 2)" if what? that just generates a number, it does not compare anything:confused:

The reason why a char array would be better is because they are easier to handle for a beginner, and they are more efficient at this particular task;)

He want it to give like these results:
"macbook" -> "mcaoobk" or "mocobak"

If you are using a char array you can with ease take out the first and last letter, scramble the rest and then put it back together again:)
 

ElderKingpin

Post in the anime section, or die.
Reaction score
134
thats for one word. there was to be an array variable that can capture every single letter that could be inputted into each slot. Then there would have to be another line of code that finds the first and last letter, not the first and seventh letter.

But i dont know how to do that, or the stuff slapshot just posted :/
 

Slapshot136

Divide et impera
Reaction score
471
mine wasnt really meant to be copy-pasted since it has it's own flaws due to me doing it in like 2 minutes, but as a starting point, so let me explain it

first the
Code:
string scramble(string);
that's a function prototype, it sets up so that the function scramble can be used anywhere after that line in the program

my program scrambles it in this fashion

it makes an empty string, and then for each letter in the input, it either adds it to the front of that string or the back of that string, randomly using
Code:
if (rand() % 2)
(that just is a random 50-50 chance)
and then repeats it 10 times (10 because i put a 10 here) to make it sufficiently random
Code:
for (int i = 0; i < 10; i++)
and then returns the now randomized string

the problems with doing it this way are:
1. i was lazy and forgot to return 0 at the end of main
2. it will always give the same result if you run it again, since i did not randomize the seed
3. there is probably a more efficient way to do this
4. the 10 passes should be declared as a constant to allow easy modifications

any more questions about what i posted?

p.s. to use a string like a char array, take this example

string str = "asdf";
str[0] is equal to 'a' now, as the first character in "asdf"
str.length() gives 4, since that is the number of characters in "asdf"
so combining those to
str[(str.length() - 1)] gives you the last letter of the string ('f')
(you need the -1 because the first character is 0 and not 1)

p.s.s.
"give a man a fish, and he wont be hungry for that day, but give a man a fishing rod..
give a man a fishing rod and he'll poke yer eye out!"
 

Samael88

Evil always finds a way
Reaction score
181
But i dont know how to do that, or the stuff slapshot just posted :/

That was why I posted the links to those tutorial sites;)
I know that it looks really overwhelming, it did for me as well once and still does sometimes:rolleyes: But as with everything else, you can't just throw yourself into it. A wordscrambler is a fairly easy thing to start out with once you understand the basic logic and princips of c++:)
So download dev-c++ or some other compiler, I strongly suggest dev-c++ tho, since it has a clean look and is not do difficult to use for basic programs.
And start reading those tutorials, and if you want any help you can either write in this forum, ask your dad or even PM me directly. I am always ready to help a fellow programmer in any way I can.

I will go thru the basic hello world program here for you just to get you started:

Code:
#include <iostream.h> //basic header file that is almost in every program.
#include <conio.h> // This is actually an old C header that I preffer to use for the getch() function.

int main() // This is the declaration of your main function, it is actually the main function and should always be there.
{ // Start of a function, note that this is a curly bracket.
    std::cout<<"Hello world"; // displays the message "Hello world" to the screen, notice "std::" I use that instead of "using namespace::std" to aboid errors.
    getch(); // this is a function-call, what this function does is basically pause the program so that you need to press a key to continue
    return 0; // this is a return statement, it is nessecary to return a int when the program is declared as "int"
} // End of a function, note that this is a curly bracket.

I hope that this might clear up some things for you, if not then just ask:thup:

Edit: Slapshot, I apologize then, I did not know about the "str[0]" I thought that only applied for chars:( I have not looked into strings that much since I am currently using SDL and it demands chars for it's text functions:(
 

Samael88

Evil always finds a way
Reaction score
181
so visual C++ 2008 isnt a good idea?

If you like it use it.
I preffer using dev-c++ because I preffer a clean enviroment compared to the "oh, shiny concept" that microsoft has applied to their products:p And don't pretend you don't know what I mean:p

I don't think that there are any huge differences between the two other than the looks though, at least not that i know about:eek:
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
If you like it use it.
I preffer using dev-c++ because I preffer a clean enviroment compared to the "oh, shiny concept" that microsoft has applied to their products:p And don't pretend you don't know what I mean:p

I don't think that there are any huge differences between the two other than the looks though, at least not that i know about:eek:

Dev-C++ and Code:Blocks are very similar. Though I recommend you use Code:Blocks since it's cross-platform Dev-C++ is a fine windows IDE.

Please for the love of god don't use VC++.
 

Icyculyr

I'm a Mac
Reaction score
68
The best thing you can do OP is try them all. I'll vouch for VC++, it's easy to use imo.
I find the VC++ IDE + MSDN documentation + a good C++ forum is good.
Use what you like best.
 

ElderKingpin

Post in the anime section, or die.
Reaction score
134
what happens when you want to scramble more then one word. a paragraph maybe.

Have a function that takes every space (considering a space means separation of words) and check the integer before and after that. If it is equal to an array (a,b,c etc., skipping periods and commas) then it would take letters in-between the two letters and scramble them.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top