Skip to content

Instantly share code, notes, and snippets.

@ernado
Created November 4, 2012 18:43
Show Gist options
  • Select an option

  • Save ernado/4012994 to your computer and use it in GitHub Desktop.

Select an option

Save ernado/4012994 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <stdlib.h>
using namespace std;
int length(char *str)
{
int n = 0;
while (str[n]!=0) n++;
return n;
}
int main()
{
char *str = new char[80];
cout << "Enter string: ";
cin >> str;
cout << length(str) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment