Skip to content

Instantly share code, notes, and snippets.

@mortie
Created August 26, 2016 12:51
Show Gist options
  • Save mortie/d98f9e9fdd26510cda1e9b85e8c57c2a to your computer and use it in GitHub Desktop.
Save mortie/d98f9e9fdd26510cda1e9b85e8c57c2a to your computer and use it in GitHub Desktop.
int stringsum(char* str)
{
int sum = 0;
char c;
int i;
for (i = 0; (c = str[i]); ++i)
{
if (c >= 'A' && c <= 'Z')
sum += c - 'A' + 1;
else if (c >= 'a' && c <= 'z')
sum += c - 'a' + 1;
else
return -1;
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment