And where are the brackets after the loop and the sum?
Type: Posts; User: andor
And where are the brackets after the loop and the sum?
The program is simple but conio.h is not standard library so the function getch() also is not standard. Remove the included library and instead of getch() use getchar().
Asume that you define function like this:
int foo(void *);
than you can pass to function different number of arguments. Okay its only one real argument but void * can point to array of...
int main()
{
/* your code going here */
return 0;
}
Did you try to write something? Well you should read char by char and find out some logic to convert it to decimal
I meant getch is not standard
No its not standard. Use getchar instead
try
plyr = &pone;
this is wrong
scanf("%s", &selection); use this instead
getchar(); /* kludge */
selection = getchar();
becouse selection is single char. Read this. When you use switch always use also...
Yes I think splitting the chars of the input is good idea. To recognise capitals you can use funcs as islower or isupper in ctype.h header. So if there is no space (' ') between chars than its OR,...
Instead of strlen in loop, calculate the length of cur in front of the loop.
I agree.
Your code doesn't compile without errors.
Don't tell me that you searched the internet and you did't find any source code.
>have tried for 3 years to learn everything about c
>i have succeeded nothing. i cant even print simple phrases
One of these two is false.
Its declared as static.
You need to declare the inarg (for example after static declaration
int inarg(char);) func or define it before gettok func.
There are 255 of them plus NULL. So from 0 to 256. You can printf like printf("%c %d 0x%x\n", i, i, i); in aloop afcourse.
link
Or easier
#include <stdio.h>
int main()
{
char crap[2] = {'1', '3'};
int total = 0;
int i;
U forgott just a little thing
#include <stdio.h>
#include <stdlib.h>
int main()
{
char tmp[2] = {'\0', '\0'};
char crap[2] = {'1', '3'};
int total = 0;
No. But U can do like this
char tmp[2] = {'\0', '\0'};
for (i=0; i< length; i++)
{
tmp[0] = crap[i];
total += atoi(tmp);
}
watch the Ascii table and U will understand. '0' is char and it's 0x30 in ascii and crap[0] is '1' also char and in ascii represantation is 0x31. Substracting the two U get the right result
U mean something like this
#include <stdio.h>
int main()
{
char crap[] = "123";
int biggerCrap = crap[0] - '0';
printf("\n%d\n", biggerCrap);
return 0;
printf("\n%d\n", crap[0] - '0');