cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/12/03:20:41

From: Maxximo <mssmsoft AT my-dejanews DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with coding
Date: Mon, 12 Apr 1999 06:34:19 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 32
Message-ID: <7es45b$it$1@nnrp1.dejanews.com>
References: <370ED5BE DOT CDBC48F1 AT mypad DOT com>
NNTP-Posting-Host: 138.132.53.11
X-Article-Creation-Date: Mon Apr 12 06:34:19 1999 GMT
X-Http-User-Agent: Mozilla/3.04Gold (X11; I; OSF1 V4.0 alpha)
X-Http-Proxy: 1.0 x2.dejanews.com:80 (Squid/1.1.22) for client 138.132.53.11
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <370ED5BE DOT CDBC48F1 AT mypad DOT com>,
  Fang <fang0654 AT mypad DOT com> wrote:
> I am pretty new to c, and I'm trying to read from a file into a variable
> string list..  I'm trying to do it like this:
>
> int main()
> {
> char test[10][20],*a;
> FILE *fp1;
>
> fp1 = fopen("test.dat","r");
>
> a = fgets(test[10],20,fp1);
>
> }
>

Hi Dan,
There is an error in your code: When you declare an array of 10 elements you
must number they from 0 to 9 and not from 1 to 10.
When you declare:
	char test[10][20]
you can use:
	test[0][0]...test[0][19],test[1][0]....test[9][19]

I hope this help you,
Maxximo



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019