Thread: Array from lines in text document

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

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, 08: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, 11:53 AM
  4. lines of a text file
    By face_master in forum C++ Programming
    Replies: 8
    Last Post: 11-06-2001, 07: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