Thread: Please help me finding the error... :(

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    82

    Please help me finding the error... :(

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    int main()
    {
        FILE *search;
        FILE *from;
        FILE *out;
    
        char fro[100][50];
        char sear[50][50];
        from=fopen("from.txt","r");
        out=fopen("out.txt","w");
        int i=0;
        while(!feof(from))
        {
            fscanf(from,"%s",fro[i]);
            i++;
        }
        fro[i]="nono";
        int j=i;
        i = 0;
    
        search=fopen("search.txt","r");
        while(!feof(search))
        {
            fscanf(from,"%s",sear[i]);
            i++;
        }
        sear[i]="nono";
        int k=i;
        int l=0;
        i=0;
        while(!feof(from))
        {
            while(from[i] != "nono")
    
            {
    
                for(i; i <k; i++)
                {
    
                    for(l; l<j; l++)
    
                    {
                        if(sear[l] == fro[i])
                        {
                            fprintf(out,"%s,",sear[l])
                        }
                    }
    
                }
            }
    
        }
    
    
        getch();
        return 0;
    }
    error: incompaitable types when assigning to type 'char[50] from type 'char*

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    line 20 and line 30 ... use strcpy()

    FWIW... Your compiler should have been complaining about this and most compiler warnings and errors include the line number of the offending code.
    Last edited by CommonTater; 01-03-2012 at 03:42 PM.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You also need to use strcmp to compare strings in C. You can't just do this:
    Code:
    while(from[i] != "nono")
    or this:
    Code:
    if(sear[l] == fro[i])
    You're also using feof wrong. Search the FAQ on this site about that one.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Don't waste your time iMalc, he spawned this duplicate thread and then gave up.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Dupe closed
    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. need help in finding the error in my code
    By zeybek258388 in forum C Programming
    Replies: 5
    Last Post: 12-23-2011, 04:38 PM
  2. new to C & need help finding parse error
    By dsemel in forum C Programming
    Replies: 3
    Last Post: 02-10-2011, 01:42 AM
  3. Help finding the error
    By C++Noob316 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2009, 01:16 PM
  4. Need help finding error
    By chorney in forum C++ Programming
    Replies: 13
    Last Post: 01-15-2007, 12:16 AM
  5. error about not finding main, when its there.
    By c++.prog.newbie in forum C++ Programming
    Replies: 5
    Last Post: 05-29-2006, 12:18 AM