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
Airida [17]
4 years ago
6

Write a program that removes all spaces from the given input.

Computers and Technology
1 answer:
sasho [114]4 years ago
5 0

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

char *removestring(char str[80])

{

   int i,j,len;

   len = strlen(str);

   for( i = 0; i < len; i++)

   {

       if (str[i] == ' ')

       {

           for (j = i; j < len; j++)

               str[j] = str[j+1];

           len--;

       }

   }

   return str;

}

int main ()

{  

char  str[80];

   cout << "Enter a string : ";

   cin.getline(str, 80);

   strcpy(removestring(str), str);

   cout << "Resultant string : " << str;

   return 0;

}

In this program the input is obtained as an character array using getline(). Then it is passed to the user-defined function, then each character is analyzed and if space is found, then it is not copied.

C++ does not allow to return character array. So Character pointer is returned and the content is copied to the character array using "strcpy()". This is a built in function to copy pointer to array.

You might be interested in
What are two example of ways an electronic record may be distributed to others?
murzikaleks [220]
By email or publishing on the internet, I hope that helps!
4 0
3 years ago
Which of the following is the best example of a manager with a delegator leadership style
Vera_Pavlovna [14]
I think the answer should be answer D.
8 0
3 years ago
Read 2 more answers
Choose the correct term to complete the sentence.
Andre45 [30]

Answer:

Technology

Explanation:

Edge 2021

8 0
3 years ago
Implement the function first chars() that takes a list of strings as a parameter and prints to the screen the first character of
Fiesta28 [93]
Def firstChars( word ):
   if( word ): # make sure word has characters
       print( word[ 0 ] ) # print the first character (Python 3 syntax)
3 0
3 years ago
It can be hard to get close enough to photograph animals in the wild true or false
marysya [2.9K]

Answer:

True

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Businesses use spreadsheets to keep track of financial________.
    14·1 answer
  • Suppose you're currently completing an examination online. When you're finished, you click on Reset Exam. Why would you do this?
    8·1 answer
  • Analyze the following code: class Test { public static void main(String[] args) { System.out.println(xMethod((double)5)); } publ
    7·1 answer
  • In client server network, there is no central server //// true or false​
    8·1 answer
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • Which of the following “invisible” marks represents an inserted tab?
    11·2 answers
  • Which of these is the fastest transmission medium?
    11·2 answers
  • Question No. 5:
    7·1 answer
  • How are comments in a Java program treated by the compiler?
    14·2 answers
  • Define management styles
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!