Hey, I'm not sure how to do this. I know how to convert a char into an int, getting the ascii value, or the numeric value, but that's not what I want to do.

Basically I have a CHAR, I give it a value, usually a short sentence, then I display it on screen, but I have a boarder thats dependent on the length of that sentence, so if I could get an interger representing the length (how many characters), that would help me A LOT.

How can I get it to convert for example like, the CHAR is "Hello There" after converting to an INT it should output 11, as there are 11 characters including the space...

Hopefully you guys understand, anyone able to help me out?

Thanks so much!

/* Wap to input a string and calculate its length  */
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
int len=0,i;
char str[50];
cout<<"**** Atishay c++ programming LTD. ****" <<endl<<endl;
cout<<"Input a string (word)"<<endl;
gets(str);
for(i=0;str[i]!='\0';i++)
{
len++;
}
cout<<"Your entered string has length of  "<<len<<endl;
getch();
}
This article has been dead for over six months. Start a new discussion instead.