Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode-users Digest, Vol 3, Issue 705




On 01.11.2006, at 06:20, A.J. wrote:

On Oct 29, 2006, at 4:10 PM, adamh wrote:

...
cin.getline(strn_text, 255);
...

but when I put this into xcode, it gives me the following errors:
Invalid conversion from 'char' to 'char*'
initializing argument 1 of...

What is wrong with this?

My guess is strn_text is a char rather than an array or a pointer to
an array of chars.

-- Steve Checkoway

Thank you for answering my question.
If strn_text was a char, wouldn't that defeat the purpose of getLINE? I thought it might be a pointer, but that didn't make any sense to me... putting a pointer in for the function works, but it doesn't produce the results that I was looking for, plus wouldn't it be redundant to have 2 arrays doing the same job?

No, you probably do mix things up.

The function reads a line of text from input (in your case max 255 char). These chars must be put somewhere - and that is where the char* comes into play. You allocate (statically or dynamically) at least 255 bytes of storage and pass a pointer to the beginning of this memory area to the function. The function then puts the read chars there.

char strn_text[256];  // give it one more than absolutely needed. I never know if the string end null is included or not
cin.getline(strn_text,255);

This issue is plain old C. Your problem has noting to do with C++

Have fun
---markus---




+-------------------------------------------+
| My computer's Stats                      |
| Mac OS 10.4.7                                |
| 1 Ghz Apple Powerbook G4        |
| Xcode v. 2.2                                    |
+-------------------------------------------+

All help is appreciated and thanks in advance.

~ < [ / adamh \ ] > ~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please keep your posts straight and
to the point. Also please comment
the code you use as I am still learning
OpenGL and Xcode and may not yet
understand the meaning of the command.
 Thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


Don't miss my latest project at http://blindpromo.com


Markus Ruggiero

rucotec consulting and technologies    email     mailto:email@hidden

rucotec GmbH                           web       http://www.rucotec.ch

Steinentorstrasse 8             

4051 Basel                             Mobile    +41 (0)79 508 4701

Switzerland                            Phone/Fax +41 (0)61 271 4990



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Re: Xcode-users Digest, Vol 3, Issue 705 (From: "A.J." <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.