Given a string on one line, output the length of that string. End with a newline.
Ex: If the input is:
Fuzzy bear
the output is: 10
#include <iostream>
using namespace std;
int main() {
char inputString[1000];
int length=0;
cout<<"Enter a String: ";
gets(inputString);
for(int j=0;inputString[j]!='\0';j++){
length++;
}
cout <<"Length: "<< length<< endl;
system("pause");
return 0;
}
Comments
Leave a comment