Hello to all after a long time How are you?
well I face problems with the input when I am using the code below
Code:
#include <stdio.h>
#include <stdlib.h>
#define N 255
int main()
{
char array[N];
char c;
int i=0;
int conv; //conventer
int count;
printf("Give the number of elements: \n");
scanf("%d",&count);
for(; i<count; i++)
{
printf("Give a number \n");
fgets(array,255,stdin);
sscanf(array,"%c",&c);
conv = atoi(array);
printf(" \n - voila - \n : %d " , conv );
}
return 0;
}
Particularly the problem is :
Code:
./atoi_test
Dwse ton ari8mo twn stoixeiwn:
3
Give a number
- voila -
: 0 Give a number
1
- voila -
: 1 Give a number
2
- voila -
: 2
There is no appropriate result as you can see..... Because when I push enter the program takes something and then prints 0 .
What the problem is???
Thank you in advance
Mr.Lnx