1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Rep Power

    All input appreciated

    Hello, I've been studying C language for a week and it is my 1st language - so I'm a total newbee. Anyhow, I went through some of the basic commands and deicded to make a little program that is going to help me in my work. Here is the gist of the program:

    I would want to put 2 arreys of values, have them compare each other and then have the program printf the values that don't match- eg if one of the arreys has a value that the other one doesn't contain.

    (I have also read somewhere how to make a .txt file in which the values can be written, but I guess there is no need to over-complicate things at first, just having a functional program is enough)

    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>

    int main()

    int base1[]= {1,2,3,4};

    int base2[]= {1,2,3,4,5,6,7,8,9};

    int x;
    int y;

    x = 0;
    y = 0;

    (x = 0, x <4 , x++);

    if ( base1[x]!= base2[y])
    {(y < 9, y++);}

    if ( base1[x] = base2[y])

    if (y = 9)
    {printf ("the number "base1[x]" has no match");}

    return 0;



    Beside several warnings, the debbuger pops out this error as well
    'expected ')' before base1' on line 31.

    All help appreciated, thank you
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    In other words, you want the union of the two sets "minus" the intersection of the sets. (set difference of the union and intersection).

    Your printf function needs a format specifier, like this:

    printf ("the number %d has no match",base1[x]);

    You have another construct that looks as if you intended a for statement but forgot to write `for'.

    (x = 0, x <4 , x++);

    You'll need to replace the semi-colon at the end of the line with brace to make a block statement including the code you want in the for loop.

    Perhaps you'd rather learn executable Iverson notation rather than c?
       1 2 3 4 (union less intersect) 1 2 3 4 5 6 7 8 9
    5 6 7 8 9
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Rep Power
    Hello and thank you for your time.

    I have made the changes you suggested and it has eliminated all but 1 error. I will try and figure it out on my own and if I can't, it just means I'm not ready to make the project at this point and time.

    As for looking into other languages, my current focus is more on getting a solid understanding of C, then on making any one specific program.

    Once again, thank you for the input and the suggestions.


IMN logo majestic logo threadwatch logo seochat tools logo