76 817
Assignments Done
Successfully Done
In June 2019

Answer to Question #34127 in C++ for Kady

Question #34127
how am i supposed to remove all leading and trailing whitespaces from an array? please give me some logic so i can work on it! :)
Expert's answer
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <string.h>
#include <iostream>

using namespace std;

const int N = 100;

char array[N];
char arr[N];

int main () {
strcpy(arr, array);
int k = 0;
int array_length = strlen(array);
while (k < array_length && isspace(arr[k])) ++k;//find number of white spaces
for (int i = k; i <= array_length; i++)
arr[i - k] = arr[i];
", arr);
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions