Cannot add two pointers...

This is a discussion on Cannot add two pointers... within the C Programming forums, part of the General Programming Boards category; I am getting an error (C2110, cannot add two pointers) on this: Code: while(iNum > 0) { iRem = iBase ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    14

    Cannot add two pointers...

    I am getting an error (C2110, cannot add two pointers) on this:

    Code:
    while(iNum > 0) 
      			{   iRem = iBase % 2;
    				iNum = iNum/iBase;
    				sBits = "" + sBits + iRem;
      
      			}
    The problem is with the "sBits = "" + sBits + iRem;." I have searched for documentation and came up with no alternatives. The prog was written in Java originally and I converted it (err, tried to anyway) to C.

    Any help is appreciated.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    what are they declared as? do they need to be pointers? Even if they do, you can always cast them to an unsigned long:
    Code:
    sBits = (unsigned long)sBits + (unsigned long)iRem;
    problem solved. But the equation makes little sense to be honest with you. You had a constant string in there. You can't add strings this way in C if that's what you're trying to do.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    66
    You cannot add strings in C/C++, you have to use strcat() and strcpy() functions...

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    102
    Dont think C will do more work to you like VB.
    Saravanan.T.S.
    Beginner.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    14
    Originally posted by achacha
    You cannot add strings in C/C++, you have to use strcat() and strcpy() functions...
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-10-2006, 06:08 PM
  2. pointers...
    By gcn_zelda in forum C++ Programming
    Replies: 2
    Last Post: 08-02-2003, 06:48 PM
  3. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 09:33 PM
  4. Pointers pointers pointers....
    By G'n'R in forum C Programming
    Replies: 11
    Last Post: 11-02-2001, 01:02 AM
  5. Pointers pointers pointers...
    By SMurf in forum C Programming
    Replies: 8
    Last Post: 10-23-2001, 04:55 PM

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