nirav99,
Use BB code tag. Source program must be surrounded with BB code tags: See # icon at toolbar and also read How to use bb code tags? .
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
Change to , that's the standard C++ way.
Also delete the line cin >>passage . You're already taking in input with getline(), so no need to do it twice.
And also change int space; to int space = 0; . How can your program ++ if it doesn't know the variable's initial value?
Also put this line: cout<<"the number of spaces is"<<space; outside your for loop. You only want to display this messsage once right?
[edit]
Also ( :) ) , you might want to put a cin.get() at the end of your loop (right after you output your message. This keeps the console open for you to read what the output of your program is. If you don't put it there, your console window will disappear to fast.
You could also run it from a console window you've already opened, but my guess is that you do not yet know how this works.
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
I've editted my previous post, you might want to read it.
>> now it says comparison between unsigned and signed integer
It's right. This line : for (int i = 0; i < passage.length(); i++) compares an unsigned integer (returned by the function length(), with an signed integer (your int i)
To solve this warning, just change it to: for (unsigned int i = 0; i < passage.length(); i++)
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
no no..
loop is not going infinite, loop is running equal to the numbers of character in a string which you have entered..
i have stored that character in integer variable " n " using " strlen(input string) " function.
and in case of "/n" i think it may not be consider as a member of string..
What the hell are you talking about?
Anyway: The problem was already solved, you should read all the replies before you make a reply yourself.
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
Mr xyz...
for your kind information..
i was solving his confutation and i think he may got it...
its non of your business..
It's niek_e not xyz. Why is this non of my business? I helped the OP to solve the problem?Mr xyz...
and also mind your language, dont proud or shout to be "nearly a posting maven".
"nearly a posting maven" is just a title I got for posting more then 2000 (?) posts. Just as your title is "newbie poster" because you haven't posted very much yet. Can't do anything about it, not my choice.In past when u newly joined "daniweb" as i have joined yet, your situation might was like mine..
okay..
No, my situation wasn't like yours at all. I read the rules for example, which clearly state:
- don't give away homework
- use code-tags
- use proper language/grammar
- don't bump:
s
^ What?
Why did you repost your original post? It still doesn't make much sense, even if you post it twice.
- What strlen() are you talking about?
- "/n" is not the same as '\n'
- a character is not a member of a string
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403