| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Beginner Question...
Well I was reading tutorials over at cprogramming.com and I found these very good tutorials.
It said to use cin.get() to make it so a console wont like close right after program is done running. It worked when I was using the int variable for inputing a number then saying what number you typed in. This worked just fine, the program didnt exit right after till I hit enter, but when I used the char variable to store words it exits anyways, is there another command to make it not exit when using char variables, and is char the right variable to hold text strings?... If im not mistaken it holds 256 characters, but I could be wrong. If someone could point me in the right direction with maybe a link or helping me out... it would be sweet :-D. Also if you have a good site with beginner tutorials it would be good perferably about C++ varibles ... I've programed in other languages and understand the concept of program just dont know the C++ syntax and all the different commands for C++ alls I know is there is char for characters, int for integers, and thats it... I know there is float.. but whats a floating point number? and double float, and bool or somthing like that.. I would like some help with learning these, any tutorials would be appriciated... Thanks in advance, -- CrYpTiC N1Nj4 |
|
#2
|
|||
|
|||
|
Not sure about stopping a program exiting straight away but its probably due to the slight misunderstanding you have about chars. A char stores one character using 256 bits (1 byte). To store strings of text you either need to use the C++ string class or character arrays. By trying to store more than one character where you only have space for one this is probably why its making it passed the cin.get().
In answer to your other questions, a floating point number is one with a decimal point in it such as 1.2345. Its called a 'floating' point since it uses different numbers of bits for different parts depending on the size of the number (you don't need to worry about the details). A double precision floating point number is one that can store twice as many values (obviously using twice as many bits to do so). Not sure about tutorials though so hopefully someone else can point you in the right direction. -KM- |
|
#3
|
|||
|
|||
|
ohhh so char only holds 1 character thats 256bits.. Thats where I must have mis-read the tutorial.
Also I figured that there would just be an easy varible for text strings.. But I guess not hehe.. My tutorial is getting into arrays soon so I guess ill figure that part out later on today. Hope I didnt make anyone mad for such a dumb question. Thanks again, -- CrYpTiC N1Nj4 |
|
#4
|
|||
|
|||
|
Not a dumb question at all. Saying this is what I know about a topic but something must be wrong please help is fine. What we don't like to see is 'Here's my code, it doesn't work, fix it for me'.
Keep up the good work, all the best with the tutorials, -KM- |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Beginner Question... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|