![]() |
| | #1 |
| Registered User Join Date: May 2006
Posts: 18
| |
| cgsarebeast is offline | |
| | #2 |
| Registered User Join Date: Feb 2006
Posts: 304
| char is the data type for storing single characters... Code: char x = 'c'; //variable x holds the letter 'c' |
| Bench82 is offline | |
| | #3 |
| Registered User Join Date: May 2006
Posts: 18
| thanks agian Bench82 how u hold multipule charaters |
| cgsarebeast is offline | |
| | #4 | |
| Registered User Join Date: Feb 2006
Posts: 304
| Quote:
Code: #include <iostream>
#include <string>
using namespace std;
int main()
{
string s = "Hello, World";
cout << s;
cin.get();
}
| |
| Bench82 is offline | |
| | #5 |
| Registered User Join Date: May 2006
Posts: 18
| o ic thanks but I'll give u an example: Code: #include <iostream>
using namespace std;
int main ()
{
cout<<"Name 1.0 \n";
cout<<"Please Press Enter \n";
cin.get ();
int x;
cout<<"Please Input your name: ";
cin>> x;
cin.ignore ();
cout<<"Is this your name?: "<< x <<"\n";
cin.get ();
}
well ne ways I want that code 2 display a letter instead of a number and I dont know what varible 2 use or even if u use one thanks..... |
| cgsarebeast is offline | |
| | #6 |
| Registered User Join Date: May 2006
Posts: 18
| oh and yes I'm useing C++ |
| cgsarebeast is offline | |
| | #7 |
| Registered User Join Date: Jan 2005
Posts: 7,137
| Use the string variable that Bench82 showed you. He showed output, but it should be easy to change to input if you know how to input a number. |
| Daved is offline | |
| | #8 |
| Registered User Join Date: May 2006
Posts: 18
| thanks, but with that how could the user change it like if I put a set value than if I put the value a sally than if there names not sally it would work? |
| cgsarebeast is offline | |
| | #9 |
| Registered User Join Date: Jan 2005
Posts: 7,137
| Just replace int in your code with string (and add the #include <string>). They are both types that can be used in the same way in this case. Then try it out and ask questions about the exact code if you get stuck. |
| Daved is offline | |
| | #10 |
| Registered User Join Date: May 2006
Posts: 18
| YaY thanks Daved... |
| cgsarebeast is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Generating random letters | ominub | C Programming | 6 | 04-29-2009 01:12 AM |
| need to count individual letters in input | epox | C Programming | 12 | 05-22-2006 06:32 AM |
| Counting letters and digits | FeNCinGeR | C++ Programming | 3 | 04-06-2006 11:39 AM |
| problems storing values in varibles | stodd04 | C Programming | 7 | 02-08-2005 11:56 AM |
| Switching letters | XiReDDeViLiX | Windows Programming | 4 | 06-06-2002 06:48 AM |