ANSWERS: 2
  • In what? In a string? Its very easy: ... ... #include <string.h> ... ... int main(int argc, int *argv[]) { int a; char s[80]; ... ... a=strlen(s); ... ... The strlen function: int strlen(const char *a) defined in string.h counts the number of characters within the string pointed to by a and returns the value. The null character at the end is not counted.
  • If you are working in ASCII characters then you can do something like this: int main(char *str) { int values = 0; int check[256]; check[' '] = 1; check['0'] = 1; ... while(str) values += check[*(str++)]; return values; }

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy