Thread View: be.comp.programming
2 messages
2 total messages
Started by biffi
Sat, 14 Feb 2004 14:51
structuren inlezen en wegschrijven (in c)
Author: biffi
Date: Sat, 14 Feb 2004 14:51
Date: Sat, 14 Feb 2004 14:51
23 lines
1468 bytes
1468 bytes
ik heb eens een vraagje over de taal c,(beginner)
hoe kan je van een bepaald txt bestand een structuur inlezen als de
woorden gescheiden zijn door spaties ?
bv txt file is
telecom telenet antwerpen 120.0
elektronica ericsson brussel 123.0
.....
en de struct is:
typedef struct
{ float omzet;
char naam[LEN];
char plaats[LEN];
char spec[LEN];
} Bedrijf;
dus telecom moet in spec[LEN] komen, telenet in naam[LEN] enzo ...
alvast bedankt,
Biffi.
Re: structuren inlezen en wegschrijven (in c)
Author: Kristoffel
Date: Sat, 14 Feb 2004 16:43
Date: Sat, 14 Feb 2004 16:43
36 lines
1852 bytes
1852 bytes
biffi wrote:
> ik heb eens een vraagje over de taal c,(beginner)
>
> hoe kan je van een bepaald txt bestand een structuur inlezen als de
> woorden gescheiden zijn door spaties ?
>
> bv txt file is
>
> telecom telenet antwerpen 120.0
> elektronica ericsson brussel 123.0
> .....
>
> en de struct is:
> typedef struct
> { float omzet;
> char naam[LEN];
> char plaats[LEN];
> char spec[LEN];
> } Bedrijf;
>
> dus telecom moet in spec[LEN] komen, telenet in naam[LEN] enzo ...
>
> alvast bedankt,
> Biffi.
na
char woord[500];
FILE *in;
in = fopen (...., "r");
while ( fscanf( in, "%s", woord) != EOF)
{
/* uw algoritme */
}
fclose (in);
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads