#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char ori_str[] = "You will pay $687.71 every month for 15 years to payoff the debt";
char *str1 = NULL;
char *str2 = NULL;
double value = 0.0;
str1 = ori_str;
str2 = strchr(str1, '$');
printf("$的位置是:\n");
printf("%d\n\n",(int)(str2 - str1+1));
value = atof(str2 + 1);
printf("double value:\n\n %.2f",value);
char *s="You will pay $687.71 every month for 15 years to payoff the debt";
char *l="years";
char *p;
p=strstr(s,l);
if(p)
printf("\n%d\n",p-s+1);
else
printf("NotFound!");
}
比如这段程序就是输出years15?