Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: OnInitDialog query Pin
FlyingTinman20-Jun-05 10:10
FlyingTinman20-Jun-05 10:10 
GeneralRe: OnInitDialog query Pin
Andrew Kirillov20-Jun-05 10:38
Andrew Kirillov20-Jun-05 10:38 
GeneralRe: OnInitDialog query Pin
Trollslayer20-Jun-05 13:14
mentorTrollslayer20-Jun-05 13:14 
Questionsimple keyboard input ? Pin
bitsNbites20-Jun-05 9:04
bitsNbites20-Jun-05 9:04 
AnswerRe: simple keyboard input ? Pin
Alexander M.,20-Jun-05 9:25
Alexander M.,20-Jun-05 9:25 
AnswerRe: simple keyboard input ? Pin
David Crow20-Jun-05 9:45
David Crow20-Jun-05 9:45 
AnswerRe: simple keyboard input ? Pin
Andrew Walker20-Jun-05 14:03
Andrew Walker20-Jun-05 14:03 
AnswerRe: simple keyboard input ? Pin
ng kok chuan20-Jun-05 17:25
ng kok chuan20-Jun-05 17:25 
is there any limitations on the type used? i guess this is for a school project right? if your project does not have any limitations, use the string class.

#include <iostream>
using std::cout;
using std::endl;
using std::cin;

#include <string>
using std::string;
using std::getline;


int main()
{
string test;

cout << "name :";
getline(cin,test);


cout << "Hello " << test << endl;
return 1;
}

this effectively removes any limitiations on character size inputs, which imho, is bad. imagine you have an indian name (no offence intended) and an english name. normally indian names are longer, so if you used a larger array size, the english name wastes a lot of memory. string dynamically allocates the memory spaces, so nothing is wasted. and you don't have to explicitly deal with the memory size (i.e. no magic numbers).

lastly, you'll find that getline will require you to press return twice to get the line if u're using vc++. this is a bug in the implementation of string. follow http://www.tek-tips.com/faqs.cfm?fid=5193 to fix the bug.

hope this is clear enough.

"Learning does not make one learned: there are those who have knowledge and those who have understanding. The first requires memory, the second philosophy." - Abbe Faria, The Count on Monte Cristo
GeneralRe: simple keyboard input ? Pin
bitsNbites20-Jun-05 18:06
bitsNbites20-Jun-05 18:06 
GeneralRe: simple keyboard input ? Pin
ng kok chuan20-Jun-05 21:33
ng kok chuan20-Jun-05 21:33 
GeneralRe: simple keyboard input ? Pin
bitsNbites21-Jun-05 4:59
bitsNbites21-Jun-05 4:59 
GeneralRe: simple keyboard input ? Pin
ng kok chuan21-Jun-05 16:40
ng kok chuan21-Jun-05 16:40 
GeneralRe: simple keyboard input ? Pin
bitsNbites22-Jun-05 4:13
bitsNbites22-Jun-05 4:13 
GeneralRe: simple keyboard input ? Pin
David Crow21-Jun-05 5:27
David Crow21-Jun-05 5:27 
GeneralRe: simple keyboard input ? Pin
ng kok chuan21-Jun-05 16:32
ng kok chuan21-Jun-05 16:32 
GeneralMKS command line Pin
lynchspawn20-Jun-05 8:36
lynchspawn20-Jun-05 8:36 
GeneralRe: MKS command line Pin
Maverick14310-Jul-12 3:17
Maverick14310-Jul-12 3:17 
GeneralColored Combo Box Pin
sergeyv200220-Jun-05 8:36
sergeyv200220-Jun-05 8:36 
GeneralRe: Colored Combo Box Pin
David Crow20-Jun-05 9:47
David Crow20-Jun-05 9:47 
GeneralRe: Colored Combo Box Pin
sergeyv200220-Jun-05 10:40
sergeyv200220-Jun-05 10:40 
GeneralRe: Colored Combo Box Pin
David Crow20-Jun-05 10:54
David Crow20-Jun-05 10:54 
GeneralBinary Decision Diagram Pin
Member 142769220-Jun-05 7:26
Member 142769220-Jun-05 7:26 
GeneralRe: Binary Decision Diagram Pin
Toni7820-Jun-05 15:49
Toni7820-Jun-05 15:49 
GeneralRe: Binary Decision Diagram Pin
Member 142769220-Jun-05 18:46
Member 142769220-Jun-05 18:46 
Generalcan't find substrings in string Pin
Anonymous20-Jun-05 5:31
Anonymous20-Jun-05 5:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.