Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!grivel!gara!cfiddyme From: cfiddyme@gara.une.oz.au (Kith Kanan) Newsgroups: comp.lang.c Subject: Arrays. Message-ID: <6466@gara.une.oz.au> Date: 21 May 91 09:52:41 GMT Organization: University of New England, Armidale, Australia Lines: 43 hi, I'm new to C and have been trying out a few things and have come up with a problem. In the code below I am reading a series of three digit numbers from a file and storing them as strings in a 2-d array.When I print them out strange things happen. Can someone please tell me what is causing this and how do I prevent it. Also when I replace the fscanf function with fgets() i get errors. Why? Thanks Chris. #include main() { char array[10][3]; char s[3]; FILE *input,*fopen(); int i = 0; input = fopen("inarray","r"); while(!feof(input)) { fscanf(input,"%s\n",s); strcpy((char *) array[i],s); i++; } for(i=0;i<=9;i++) fprintf(stdout,"%s\n",array[i]); } This is the output of the program.The input file is just the first three digit's of each line. 229657659312999867555664811109 657659312999867555664811109 659312999867555664811109 312999867555664811109 999867555664811109 867555664811109 555664811109 664811109 811109 109