|
Thread: C++
-
July 21st, 2002, 09:55 PM
#21
c++
Not quite... but close. the userName[21] creates a username with up to 21 characters (which are located in positions 0-20 of the character array) Declaring a variable as just a char only allows a character, but the [] make the variable into an array of characters instead. Also, if you want, you can include string.h and use the string variable type instead. This header file will also give you more string manipulation functions/procedures.
so you mean if my program looks like this it wil work:
#include <iostream>
using namespace std;
int main void
{
char userName[100]//this allows the user to type a 100 character name
cout << "insert your name" << end;
cin >> userName
cout << "hello" <<userName<< "you are very cool"
}
Support your right to arm bears.

^^This was the first video game which i played on an old win3.1 box
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|