Hello????.......help in C++

RamboEvil
RamboEvil used Ask the Experts™
on
hi all,
i wanna make a program in c++ can read a statment and after that read character and finaly i wanna this program to tell me how many character in string"statment".
Rambo.  
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
So where's the problem ?

Author

Commented:
i can not do this program ....iam beginer in c++
Try looking at cin, gets etc options. Will solve the problem of reading in statements.

Then teh counting can be simple string logic.

Lastly, the output would be cout, puts etc.

Let me know if this helps.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
iam sorry..i not good in loops (and it needs loops)
Commented:
then practice :)
if you have visual studio or something like that... use F10 and set through the code... look that the variables... see whats going on, then you can start to understand loops.
but technically it doesn't require loops :)

I haven't done console programming so the cin and out
may be wrong... open that comp 101 book and find them
and the headers :)

simple version: (no loop version)
char string[2048]; // that should be big enough :)
cin << string;
cout >> "size:" >> strlen(string);

probably get in trouble for that if they want loops :)

so then instead of strlen(string)

// i variable maintains position in the string
for(int i = 0; // start at 0
    i < 2048; // don't go past the allocation size!
    i++){ // add 1 to the i so we go to the next position
          // at the end of the loop
  if(!string[i]) // strings typically are terminated with 0
                 // so this checks to see if its 0
     break; // found a zero, so stop the loop!
}
cout >> "size:" >> i; // output size

if you are a comp student you MUST learn loops... if you don't or can't then you should change your degree...
if your not a student, you won't be able to do much without
some form of loops..

Author

Commented:
thank u defrog iam just new with this languge

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial