1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ivann1987 [24]
3 years ago
10

LAB: Count characters - methods

Computers and Technology
1 answer:
tangare [24]3 years ago
4 0

Answer:

i hope understand you

mark me brainlist

Explanation:

using namespace std;

#include <iostream>

 

#include <string.h>

#include <stdlib.h>

#include <stdio.h>

 

#define BLANK_CHAR (' ')

 

 

int CountCharacters(char userChar, char * userString)

{

 

int countReturn=0;

 

int n = strlen(userString);

 

for (int iLoop=0; iLoop<n; iLoop++)

{

       if (userString[iLoop]==userChar)

       {

        countReturn++;

 }

}

return(countReturn);

}

 

/******************************************

    Removes white spaces from passed string; returns pointer

     to the string that is stripped of the whitespace chars;

   

  Returns NULL pointer is empty string is passed;  

     Side Effects:

 CALLER MUST FREE THE OUTPUT BUFFER that is returned

 

 **********************************************************/

char * RemoveSpaces(char * userString)

{

 

 char * outbuff = NULL;

 

 if (userString!=NULL)

 {

   int n = strlen(userString);

    outbuff = (char *) malloc(n);

 

   if (outbuff != NULL)

   {

          memset(outbuff,0,n);

          int iIndex=0;

          //copies non-blank chars to outbuff

         for (int iLoop=0; iLoop<n; iLoop++)

         {

           if (userString[iLoop]!=BLANK_CHAR)

          {

           outbuff[iIndex]=userString[iLoop];

           iIndex++;

   }

   

   } //for

         

   }

   

   }

 return(outbuff);

 

}

 

 

int main()

{

 

 char inbuff[255];

 cout << " PLEASE INPUT THE STRING OF WHICH YOU WOULD LIKE TO STRIP WHITESPACE CHARS :>";

 gets(inbuff);

 

 char * outbuff = RemoveSpaces(inbuff);

 if (outbuff !=NULL)

 {

    cout << ">" << outbuff << "<" << endl;

    free(outbuff);

    }

     

   memset(inbuff,0,255);  

   cout << " PLEASE INPUT THE STRING IN WHICH YOU WOULD LIKE TO SEARCH CHAR :>";

gets(inbuff);

 

  char chChar;

 cout << "PLEASE INPUT THE CHARCTER YOU SEEK :>";

 cin >> chChar;

 

 int iCount = CountCharacters(chChar,inbuff);

 cout << " char " << chChar << " appears " << iCount << " time(s) in >" << inbuff << "<" << endl;

 

}

You might be interested in
Select the correct answer. Which is the bottom-most layer in the OSI model?
tatiyna

Answer:

B.Physical layer

Explanation:

I am sure.Hope it helps

3 0
3 years ago
Changes in the ownership of a file do not change the amount of data that is considered to belong to a user.
professor190 [17]
False because if you edit the ownership of file it will give permissions only with the permissions you can edit file,rename,or delete file.
5 0
3 years ago
The race car driver nicknamed Neiblemeister - master of the mist, was married to what famous female aviator?
user100 [1]
<h2>ANSWER: ELLY BEINHORN</h2>

The race car driver Neiblemeister- master of the mist, was married to <em>Elly Beinhorn</em> who was a famous female aviator. In 1936 Beinhorn married the well-known racecar driver Bernd Rosemeyer, who died in a car accident years later, only ten weeks after the birth of their son Bernd. She remarried in 1941 and within a year gave birth to a much-longed-for daughter, whom she named Stephanie.

7 0
3 years ago
Read 2 more answers
Literally not even a true question, I just want to know
german
I’m here because of k12
3 0
3 years ago
Read 2 more answers
Select the correct answer.
enot [183]
It helps them raise there company up by advertisements or anything to help them grow
3 0
3 years ago
Other questions:
  • "which programming language is used within html documents to trigger interactive features?"
    10·1 answer
  • The width of a strand of fiber is 19.2 micrometers. if 1500 strands are adhered side by side, how wide would the resulting fabri
    9·1 answer
  • A personal business letter is a letter that is ____.
    13·1 answer
  • While performing Before Operations PMCS, you notice the front right tire appears slightly underinflated. What is the proper acti
    11·1 answer
  • 4. A computer architect boasted that they were able to design a computer in which every instruction occupied exactly thirty-two
    8·1 answer
  • How to make an upside down exclamation point on mac?
    8·1 answer
  • When is the kids choiceee awads?????????????????????????
    12·2 answers
  • What’s your tiktok? if u have one
    10·2 answers
  • Luis saves an attachment that he received from Kevin. Where will the attachment save by default?
    5·1 answer
  • How to find HCF and LCM of a number in Q Basic program?? ​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!