Skip to content

Instantly share code, notes, and snippets.

@hrshadhin
Created April 23, 2013 16:22
Show Gist options
  • Select an option

  • Save hrshadhin/5445064 to your computer and use it in GitHub Desktop.

Select an option

Save hrshadhin/5445064 to your computer and use it in GitHub Desktop.
calculate String length
#include<stdio.h>
#include<string.h>
int main()
{
char string[100];
printf("Enetr your string that you want to caculate its length:\n");
gets(string);
int len=0,n=0;
while(string[n] != '\0')//length calculate
{
n++;
len++;
}
printf("the string length is %d",len);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment