Array from lines in text document

This is a discussion on Array from lines in text document within the C Programming forums, part of the General Programming Boards category; Hi everyone, i have a problem but my english is poor, i'm sorry for this. i want to make a ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    Array from lines in text document

    Hi everyone,

    i have a problem but my english is poor, i'm sorry for this.

    i want to make a string array from strings in a text file.

    i try to do this but i couldn't do, where is my mistake?

    Sorry again for my bad english.


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(){ 
       
    char cumle[100],*c,*dene[50]; 
       
    FILE *input; 
       
    input=fopen("input.txt","r"); 
           
    //i want to partition this string line by line 
       
    int a=0; 
       
    while (c != NULL){ 
       c=fgets(cumle,100,input); 
       
    if (c != NULL) 
       dene[a]=cumle; 
       a++; 
       } 
           
    /* 
       //this is print all lines 
       
    while (c != NULL){ 
       c=fgets(cumle,100,input); 
       
    if (c != NULL) 
       printf("%s",cumle); 
       
    }
        */
        
    return 0;
    
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alphabetizing Lines of Text
    By Adrian in forum C Programming
    Replies: 5
    Last Post: 12-03-2007, 07:28 PM
  2. Help displaying line numbers of a text document
    By Japatron in forum C Programming
    Replies: 4
    Last Post: 05-04-2006, 01:34 PM
  3. Reading info from a text document.
    By twomers in forum C++ Programming
    Replies: 2
    Last Post: 12-13-2005, 10:53 AM
  4. lines of a text file
    By face_master in forum C++ Programming
    Replies: 8
    Last Post: 11-06-2001, 06:09 AM
  5. Text Mode to more than 25 lines
    By karsch1 in forum C Programming
    Replies: 3
    Last Post: 08-31-2001, 01:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21