![]() |
*operater and arrays
Ok the following code is being used to store an array of strings (being stored with memcpy). What is the * operater doing in the array declaration? I can't figure it out for the live of me! Is it just being used to declare 6000 elements?
:
char G_cMsgList[120*50];this is the routine used to store the Msg! I understand common things but certain thing like "cTemp + 120" is beyond me! Why would memcpy be used to store the msg's array (G_cMsgList) in cTemp them use memcpy again to store the new msg in cTemp and then take cTemp and put it in G_cMsgList again! :
void PutLogList(char * cMsg)This is used to output the msg's (WM_PAINT). The main thing i don't understand is why the the declaration for a string is char * cMsg;. :
void OnPaint()The reason for all of this is because im writting a text based rpg (still) using Win32 and I want to paint text (ofcourse). 1 first msg (line) being at the bottom of the window and each time i want to output a new msg (line) it is placed at the bottom and everything else shifts up a line. The code you see performs this action.. but i would never rip it. I want to completely understand how it was done before i attempt it (re-written). Thanks |
>Is it just being used to declare 6000 elements?
Yes. And char * cMsg; is just a pointer to the text contained in the G_cMsgList array. [EDIT] :
memcpy((cTemp + 120), G_cMsgList, 120*49); |
but why char * cMsg why not char* cMsg or char *cMsg??? Or are they all the same?
|
Yes, they are all the same.
|
Btw it's written 'operator' not 'operater'.
|
thanks nnxion i wrote these post last night after drinking a 6-pack. Anyone else have any insight about all of my other questions?
|
It isn't a matter of insight. Which question did you ask that you didn't see an answer for?
Quote:
:
memcpy((cTemp + 120), G_cMsgList, 120*49);Quote:
Okay? |
Perhaps part of the question is why use memcpy when C++ provide several abstractions for such operations. My anwser would be: I wouldn't. The code posted is probably written in C.
|
>Anyone else have any insight about all of my other questions?
I hate repeating DaWei, but what did you ask that I didn't answer? :confused: |
I guess they were anwsered! lol sorry I had more then i didn't write... so i should be able to perform the same output using a (string) vector correct?
|
| All times are GMT -5. The time now is 12:50 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC