Sunday 15 June 2014

c - How to read lines from a text file and store as char array? -


text after "itemprop =" text ">

I have an input text file with some instructions and, line 7, start with several lines of text. Something like this:

  Hi gBroThuo oWdbmna EO MT ce oneain, nDustuh o Ade DS, bpopoonf oneigno abro WMT eiw N, Yrtyt hlil T .s Ble a meyboefr rtIhoyod WLA rimw yidehl. KES, Oyn L of Fu! AcMadmdnae nddmh ITA behsctr RFT iHdo "L, sie G" Hu, N eoaecMBt- - h  

I need to be stored in a text to store characters < / Code> array (including new line characters). What functions have I read and can use four arrays to store a single to this text?

  four filebooks [Maxfile]; FILE * f; Int c; Size_t i; If (f = fopen ( "file name", "r")) {(i = 0; i & LT; (MAXFILE - 1) & amp ;! & amp; (c = getc (f)) = EOF ; ++ i) FileBuf [i] = C; Fclose (f); } And malfunction ("file could not be opened");  

Edit:. You said you wanted to leave 7 lines for the first time

  integer x; Four line [MAXLINE]; For (x = 0; x & lt; 7; ++ x) fgets (line, maxline, f); / * Leaves the first 7 lines, so now the file indicator will point to data after 7 lines * /  

No comments:

Post a Comment