Why does my c prog stop working when printing out an array

Viewed 166

In this program I'm parsing a csv file with fgets, and based on my knowledge on c prog, it turns the file into an array.

So when I print it out with printf("%s",input) I get this 10,20,30 for example, but when i include printf("%s",input[0]) the program stops working. This is the program i am working on:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct xa 
{
  int x;
  int y;
  int z;
} xo;

int main()
{
    FILE *dudufile;
    char filename[]="dodo.dat";
    char input[1679];
    dudufile=fopen(filename,"r");

    while ( fgets(input,1679, dudufile ) != NULL )
    {
        printf("%s\n",input);
        printf("%s\n",input[0]);
        struct xa;
        xo.y=input[1];
        printf("%d",xo.y);      
    }

    return 0;
}
4 Answers
Related