Hello, simple program here i can't seem to get to work. In a nutshell the program reads characters into an array using getchar and then prints them in a loop, although the numbers printed are not the ones i entered! thanks in advance
#include <stdio.h>
#define MAXSIZE 100 /*max array length*/
int arrlen(int []);
int main()
{
int c, i = 0;
int s[MAXSIZE];
while((c=getchar()) != EOF && c != '\n'){ /*while the chars read havn't reached a new line or EOF */
s[i++] = c; /*Read them into an array*/
if(c == '\n'){
s[i++] = c;
}
}
s[i] = '\0'; /* terminate the array */
for(i=0;i<arrlen(s);++i){
printf("%d\n", s[i]);
}
return 0;
}
int arrlen(int array[])
{
int i;
for(i=0;array[i] != '\0';++i)
;
return i; /*return legnth of the array*/
}