Incompatible Pointer Type

This is a discussion on Incompatible Pointer Type within the C Programming forums, part of the General Programming Boards category; I am working on a project where you have an array of structures to keep track of bank records, and ...

  1. #1
    Registered User jcramer's Avatar
    Join Date
    Oct 2003
    Posts
    23

    Question Incompatible Pointer Type

    I am working on a project where you have an array of structures to keep track of bank records, and you have to be able to do deposits, withdrawls, adding accounts, etc...

    Everything was going smoothly until I got to the part where I am coding the withdrawl command. When I go to compile my program, I get the "passing argument 2 of 'strcmp' from incompatible pointer type.

    Here's the part thats having the problem:

    Code:
    fgets(buffer, BUFLEN, file_in);
    sscanf(buffer, "%d", &withdrawl);
       for (i = 0; i < counter; i++)	 
       {
        if (strcmp(buffer, &accts[i].acctNbr) == 0)
           accts[i].acctBal = accts[i].acctBal - withdrawl;
       }
    Any help on this would be great! Thanks!
    Viva la Tutorial
    What is the meaning of life? 42 of course!

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    I don't suppose you'd mind letting anyone know what acctNbr's type is? Surely it is not an int whose address you are passing to a string comparison function in lieu of a pointer to a char.
    Last edited by Dave_Sinkula; 12-07-2003 at 01:09 AM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User jcramer's Avatar
    Join Date
    Oct 2003
    Posts
    23
    Actually yes but, should I then create another array (of int type) just so that I can compare it to acctNbr?
    Viva la Tutorial
    What is the meaning of life? 42 of course!

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    Compare two strings or two ints - so you'll have to convert one to the other.
    Take a look at atoi().

    gg

  5. #5
    Registered User jcramer's Avatar
    Join Date
    Oct 2003
    Posts
    23
    Thank you sooooo much! atoi() fixed my prog!!
    Viva la Tutorial
    What is the meaning of life? 42 of course!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. warning: assignment from a incompatible pointer type
    By enderandrew in forum C Programming
    Replies: 8
    Last Post: 09-22-2007, 04:07 AM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM

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