I am new to C, just experimenting few things. I am trying to find the maximum number or the last number within a string, exp: if I entered 1234 I should get 4 back, but the code below returns the whole thing: 1234
Is there a function (maybe called "MAX") I can use to retrieve the last number whithin a string?
Thanks for your input in advance.
-Dale
dba@datah.net
Code:#include <stdio.h> #include <string.h> main() { int a, i, j; char x[100]; printf("Please give me a string: "); scanf("%s",x); printf("\n"); i = 0; while (x[i] != NULL) { x[i] = x[i]; ++i; } printf("The maximum number within this string is %s ",x); }



LinkBack URL
About LinkBacks


