I am trying to make a program that asks the user to start typing different characters(doesn't matter what) until 'EOF'. After that I have to "printf" this array without the numbers. So something like this:
'User input':123asd (! only example)
'Output':asd (! only example)
My problem is that I can't figure out the function. I was able to achieve:
User input:asd123 (!only example)
Output:asd (!only example)
But when I turn it around(first example!) it doesn't work at all.
Even something like you are stupid use pointers instead of this would be great. I am just trying to figure it if its possible this way!!
#include <stdio.h>
void element(char a[], int d) {
int i;
for (i = 0; i <d; i++) {
if (a[i] <= '9') {
/*
..........
*/
}
}
for (i = 0; i < d; i++) {
printf("%c", a[i]);
}
}
int main() {
char a[25];
int c, i, d;
i = 0;
d = 0;
while (i < 25) {
c = getchar();
if (c =='\n') {
a[i] != c;
} else if (c == EOF) {
break;
} else {
a[i] = c;
i++;
d++;
}
}
putchar('\n');
element(a, d);
return 0;
}
if(a[i] <= '9')-->if ((a[i] < '0') || (a[i] > '9'))