trouble with pointers HELP MEEEE???

This is a discussion on trouble with pointers HELP MEEEE??? within the C++ Programming forums, part of the General Programming Boards category; HELLO all it's me once again I've just read up on the section on pointers and all the book did ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    78

    trouble with pointers HELP MEEEE???

    HELLO all it's me once again I've just read up on the section on pointers and all the book did was leave me dazed and confused. I built this program observe.
    Code:
    #include <iostream.h>
    int main()
    {
    	const int NUMCHARS = 80;
    	char strng[NUMCHARS];
    	char c;
    	char ToUpper(char ch);
    	cout<<"Enter a line of text\n";
    	cin.getline(strng,NUMCHARS);
    
    		while ((c = *strng++) != '\0') 
    		{
    			c = ToUpper(*strng);
    			
    		}
    
    		cout<<"the string with uppercase letters\n";
    		cout<<  c <<endl;
    		return 0;
    }
    
    char ToUpper(char ch)
    {
    	
    	if (ch >= 'a' && ch <= 'z')
    		return (ch - 'a' + 'A');
    	else
    		return(ch);
    }
    alrighty everything looks like it should run smoothly but I keep getting an error in regards to the "++" any input would be much appreciated thank you

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    The variable that is the array cannot be changed. For example, you can't write
    int A[10];
    A++;
    But you can assign a pointer to the base of the array: &A[0] or just A. To fix this you could write something like
    int A[10];
    int* Aptr = A;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trouble with file pointers...
    By quasigreat in forum C Programming
    Replies: 4
    Last Post: 05-19-2008, 09:12 AM
  2. Trouble with pointers..
    By elfjuice in forum C Programming
    Replies: 7
    Last Post: 11-25-2007, 01:19 AM
  3. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 11:56 AM
  4. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  5. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 07:53 PM

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