|
From: Adam J. <aj...@i-...> - 2007-07-19 22:33:07
|
The code you posted is listed below:
>>#include <iostream>
>>#include <ctype.h>
>>using namespace std;
>>int main()
>>{
>> char ch;
>> int aCnt =0, eCnt =0, iCnt =0, oCnt =0, uCnt =0, consonantCnt =0,
spaceCnt =0;
>> while ( cin >> ch )
>> switch ( ch )
>> {
>> case 'a': case 'A':
>> ++aCnt;
>> break;
>> case 'e': case 'E':
>> ++eCnt;
>> break;
>> case 'i': case 'I':
>> ++iCnt;
>> break;
>> case 'o': case 'O':
>> ++oCnt;
>> break;
>> case 'u': case 'U':
>> ++uCnt;
>> break;
>> case ' ':
>> ++spaceCnt;
>> default:
>> if ( isalpha( ch ))
>> ++consonantCnt;
>> break;
>> }
>> cout << " numero di a:" << aCnt << '\n';
>> cout << " numero di e:" << eCnt << '\n';
>> cout << " numero di i:" << iCnt << '\n';
>> cout << " numero di o:" << oCnt << '\n';
>> cout << " numero di u:" << uCnt << '\n';
>> cout << " numero di consonanti:" << consonantCnt << '\n';
>> cout << " numero di sapzi:" << spaceCnt << '\n';
>> return 0;
>>}
The problem with your code is that you do not enclose the switch statement
inside of your while loop. So what is happing is that the only line in your
program being executed is
>> while ( cin >> ch )
You need to add the brackets after the while loop and enclose the switch
statement. Once you do that, it should work,
while ( cin >> ch )
{ <--Add this openning bracket here
switch ( ch )
{
case 'a': case 'A':
.
.
.
.
} <-- Add closing bracket here.
-Adam Jones
-----Original Message-----
From: dan...@li... [mailto:dan...@li...]
Sent: Thursday, July 19, 2007 9:57 AM
To: ajones
Subject: Re: [Dev-C++] Question
This is the source code
many thanks
Danilo
---------- Initial Header -----------
>From : dev...@li...
To : "dev-c++ devc++" dev...@li...
Cc :
Date : Thu, 19 Jul 2007 08:59:23 -0400
Subject : Re: [Dev-C++] Question
> >>Hello,
>
> >>I have a problem with this program: when a give the execute comand
> >>the
> *.exe window opens but after I give the characters to switch as You
> can see on the While comand : >>while ( cin >> ch ) I can't make the
> execution of the program.
>
> >>There's a specific comand to give on the *.exe window for running
> >>the
> execution after writing on it?
>
> >>Many Thanks
>
> >>Danilo
>
> Unfortunately I am not sure what you are asking. If the program is not
> large, post the source code. How do you know that the code is not
running??
> Maybe it is running, but you haven't paused executive so you can see
> the output. If you don't pause the executive the cin will get the
> input, the program will do what it has to do and then close the console
window.
>
> -Adam Jones
>
>
>
> ----------------------------------------------------------------------
> --- This SF.net email is sponsored by DB2 Express Download DB2 Express
> C - the FREE version of DB2 express and take control of your XML. No
> limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
------------------------------------------------------
Leggi GRATIS le tue mail con il telefonino i-modeT di Wind
http://i-mode.wind.it/
|