C언어로 helloworld만 해본 나에게 너무 어렵네요.
일딴
덧셈만 좀 해볼려고 하는데
오류 뜨고 안됨.
배열에 저장만이라도 되면 좋을 텐데
좀 도와 주세용 ㅠㅠ
#include <stdio.h>
#include <string.h>
int main ()
{
int x=0, y=0;
char str[1024];
char *pch;
char *token[256];
printf(">> mycalc ");
gets(str);
int sum, i=0;
int pos;
char *poss;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," + ");
while (pch != NULL)
{
pos=i;
printf ("%s\n",pch);
pch = strtok (NULL, "+-* ");
token[i]=pch;
i++;
}
for(i=0; i<=pos; i++)
sum+=token[i];
printf("%d\n",sum);
return 0;
}
그래서 뭘 도와달라는거냐? 완성해달라고?
완성해 주면 고맙겠지만 해주진않을 것 같고 2+3 라고 치면 숫자만 분리해서 token이라는 배열에 집어 넣고 싶어요 ㅠㅠ 근데 안됨 아놔