answersLogoWhite

0

There are many ways to achieve this. Example:

#include <iostream>

using namespace std;

int main()

{

char str[256];

memset( &str, 0, 256 );

cout << "Enter a string with some spaces: ";

cin.getline( str, 256, '\n' );

int count = 0;

char * p = str;

while( p < str + 255 )

{

if( *p == 32 ) ++count;

++p;

}

cout << """ << str << "" has " << count << " spaces!" << endl;

return( 0 );

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you write c program to accept a string from the console and count number of vowels constants digits tabs and blank spaces in a string?

Read the characters one at a time, and write an "if" for each of the cases. In each case, if the condition is fulfilled, increment the corresponding counter variable.


What statement do you use to cause DBMS OUTPUT to print blank or null lines and leading spaces passed to it?

To print blank or null lines and leading spaces using DBMS_OUTPUT in PL/SQL, you can use the DBMS_OUTPUT.PUT_LINE procedure. To create a blank line, simply call DBMS_OUTPUT.PUT_LINE('');. For leading spaces, include them in the string, such as DBMS_OUTPUT.PUT_LINE(' This line has leading spaces.');. This will ensure that both blank lines and lines with spaces are correctly output.


String functions Of sql server 2005?

SQL Server provides us with a variety of string functions. Some of them are:LOWER - To convert a string to lower caseUPPER - To convert a string to upper caseLTRIM - To trim blank spaces from the left side of the stringRTRIM - To trim blank spaces from the right side of the stringSUBSTRING - To pick up specific portions of a stringREVERSE - To reverse the input stringREPLACE - To replace the character at a specified position of a string with anotheretc.


How do you get your name to be undefined on poptropica?

There is no way. You need a username and password to play, and the program will not accept all blank spaces or dashes.


Number line for 2493 3 spaces then 8008?

waht gose and the blank 2493_ _ _ _ 8008


In a java program in a return statement with string concatenation how do you print a blank line?

use "\n" between the words where you want a new line


What are the release dates for Blank Spaces - 2010?

Blank Spaces - 2010 was released on: USA: 22 February 2010 (internet)


How many blank spaces between the date and address?

The number of blank spaces between the date and address can vary depending on the formatting style used. Typically, formal letters might have one or two blank lines between the date and the address to enhance readability. However, without specific context or a sample format, it's difficult to provide an exact number.


Blank program?

_______ program


Es-pin mind quiz code blank with spaces?

Paper with spaces


What does a short line in front of the word program mean---- program?

blank program


Brook is to river as blank is to rope?

string