Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Variable length of String Pin
Richard MacCutchan28-Jun-11 21:48
mveRichard MacCutchan28-Jun-11 21:48 
AnswerRe: Variable length of String Pin
Code-o-mat28-Jun-11 22:17
Code-o-mat28-Jun-11 22:17 
QuestionRe: Variable length of String PinPopular
David Crow29-Jun-11 3:12
David Crow29-Jun-11 3:12 
AnswerRe: Variable length of String Pin
Maximilien29-Jun-11 3:56
Maximilien29-Jun-11 3:56 
GeneralRe: Variable length of String Pin
Albert Holguin29-Jun-11 9:22
professionalAlbert Holguin29-Jun-11 9:22 
GeneralRe: Variable length of String Pin
Maximilien29-Jun-11 9:39
Maximilien29-Jun-11 9:39 
GeneralRe: Variable length of String Pin
Albert Holguin29-Jun-11 11:32
professionalAlbert Holguin29-Jun-11 11:32 
AnswerRe: Variable length of String Pin
Stefan_Lang30-Jun-11 2:06
Stefan_Lang30-Jun-11 2:06 
I agree that this requirement is weird, specificallly as you are using cin and cout, which are also part of the STL, and internally do use dynamic container classes! Not to mention that for the purpose of writing and reading simple char arrays, cin and cout are hopelessly inefficient, you'd be better served with puts() and _getch().

Since you don't know the length of the input in advance, the only way to ensure you have a sufficiently large buffer is using a container that dynamically resizes itself. If you don't want to use std::string, or other string classes like CString, then I suppose using std::vector is out of the question as well? If that is so, you have to implement a dynamical container yourself. I don't see why anyone would want you to waste time on that though, unless it is for homework.

Anyway, what you need to do is
1. use or implement your own dynamical container, such as std::vector
2. make a loop to read the input, using _getch() to read individual characters
3. for each character, check whether it belongs to the input, or indocates the end of input; if input, store it in your dynamical container.

Also, at the end of the program, don't forget to release the memory that you allocated for your dynamical container. std::vector or std::string will do that for you, but if you have your own class, you need to take care of it yourself.
QuestionImplementing MD5 algorithm in C++ Pin
pix_programmer28-Jun-11 19:38
pix_programmer28-Jun-11 19:38 
AnswerRe: Implementing MD5 algorithm in C++ Pin
Peter_in_278028-Jun-11 20:08
professionalPeter_in_278028-Jun-11 20:08 
AnswerRe: Implementing MD5 algorithm in C++ Pin
Mark Salsbery29-Jun-11 9:26
Mark Salsbery29-Jun-11 9:26 
Questionknowing file version Pin
Sakhalean28-Jun-11 19:37
Sakhalean28-Jun-11 19:37 
AnswerRe: knowing file version Pin
pix_programmer28-Jun-11 19:45
pix_programmer28-Jun-11 19:45 
QuestionKnowing path of MFC executable Pin
Sakhalean28-Jun-11 18:35
Sakhalean28-Jun-11 18:35 
AnswerRe: Knowing path of MFC executable Pin
ShilpiP28-Jun-11 19:02
ShilpiP28-Jun-11 19:02 
GeneralRe: Knowing path of MFC executable Pin
Sakhalean28-Jun-11 19:20
Sakhalean28-Jun-11 19:20 
GeneralRe: Knowing path of MFC executable Pin
pix_programmer28-Jun-11 19:34
pix_programmer28-Jun-11 19:34 
GeneralRe: Knowing path of MFC executable Pin
Randor 29-Jun-11 1:33
professional Randor 29-Jun-11 1:33 
GeneralRe: Knowing path of MFC executable Pin
Albert Holguin29-Jun-11 9:17
professionalAlbert Holguin29-Jun-11 9:17 
AnswerRe: Knowing path of MFC executable Pin
Charles Oppermann4-Aug-11 13:02
Charles Oppermann4-Aug-11 13:02 
AnswerRe: Knowing path of MFC executable Pin
softwaremonkey28-Jun-11 20:10
softwaremonkey28-Jun-11 20:10 
AnswerRe: Knowing path of MFC executable Pin
Chuck O'Toole29-Jun-11 15:57
Chuck O'Toole29-Jun-11 15:57 
QuestionCall Invoke() fails [modified] Pin
yaxiya28-Jun-11 16:29
yaxiya28-Jun-11 16:29 
AnswerRe: Call Invoke() fails Pin
David Crow28-Jun-11 16:53
David Crow28-Jun-11 16:53 
GeneralRe: Call Invoke() fails Pin
yaxiya28-Jun-11 17:05
yaxiya28-Jun-11 17:05 

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.