Error: incompatible types in assignment & invalid operands to binary

This is a discussion on Error: incompatible types in assignment & invalid operands to binary within the C Programming forums, part of the General Programming Boards category; I'm new to C and here's my program.Lines in red are the errors occurred: (USACO PROB:GIFT) Problem 77: Greedy Gift ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    2

    Error: incompatible types in assignment & invalid operands to binary

    I'm new to C and here's my program.Lines in red are the errors occurred:
    (USACO PROB:GIFT)
    Problem 77: Greedy Gift Givers

    #include <stdio.h>

    int namelookup(char keyword[20],char nametable[11][20]){
    for (int i=0;i<=10;i++)
    if (keyword == nametable[i])
    return i;
    printf ("%s not found",keyword);
    return -1;
    }
    int main () {
    FILE *fin = fopen("gift.in","r");
    FILE *fout = fopen("gift.out","w");
    char name[11][20];
    int account [11][2];
    char np,looper,nameid,noportion,looper2;
    char namecache[20];
    fscanf (fin,"%d",np);
    for (looper=1;looper<=np;looper++)
    fscanf(fin,"%s",name[looper-1]);
    for (looper=1;looper<=np;looper++){
    fscanf(fin,"%s",namecache);
    nameid=namelookup(namecache,name);
    fscanf(fin,"%d %d",account[nameid,0],noportion);
    account[nameid,1] = account[nameid,0];
    Error: Incompatible types in assignment
    for (looper2=1;looper2<=noportion;looper2++){
    fscanf(fin,"%s",namecache);
    account[namelookup(namecache,name),1] += (account[nameid,0] / noportion);
    Error: Invalid operands to binary
    account[nameid,1] -= (account[nameid,0] / noportion);
    Error: Invalid operands to binary
    }
    }
    for (looper=0;looper<=(np-1);looper++)
    fprintf (fout,"%s %d\n",name[looper],(account[looper][1]-account[looper][0]));
    return 0;
    }

    Environment x86 Mac OS X 10.6, Xcode 3.1.4

    Can someone please explain why these errors would happen and give me hints to correct them?
    Thanks a lot.

  2. #2
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    http://cboard.cprogramming.com/c-pro...e-posting.html

    Twodimensional arrays are addressed as arr[1][2], not arr[1, 2].

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    2
    Build Succeeded. Thanks a lot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  2. Flood of errors when include .h
    By erik2004 in forum C++ Programming
    Replies: 14
    Last Post: 12-07-2002, 07:37 AM
  3. misc.c:3210: invalid operands to binary +
    By Unregistered in forum Linux Programming
    Replies: 2
    Last Post: 07-19-2002, 08:00 AM
  4. Replies: 6
    Last Post: 04-12-2002, 09:33 AM
  5. invalid operands
    By simhap in forum C++ Programming
    Replies: 5
    Last Post: 10-08-2001, 11:23 AM

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