it helps allot, thank you for spending the amount of time that it took to type that long thing :) I know how pointers and stuff work, its just, there are a couple of things that are in the gray, as in (I dont know if it will do the exact thing i want it) i guess i should use strcpy() for a pointer, "it doesnt make sense to do so :)" i think i should print this out... :) Thanks for your time! ~SilverShalkin :rose:
SilverShalkin
Posts
-
experimenting... "to understand pointers more" -
experimenting... "to understand pointers more"would that work? - ill insert some of the code replies and try to understand this more... thanks guys! :) ~SilverShalkin :rose:
-
Linking Errordid you include the header? :) i've done that alot :( ~SilverShalkin :rose:
-
experimenting... "to understand pointers more"but i want to point to character, if i dake the address (&) off, it wouldnt be point to character would it? so i would have to declare my pchar like char *pchar[6]; pchar[0] = &character[0]; pchar[1] = &character[1]; pchar[2] = &character[2]; pchar[3] = &character[3]; pchar[4] = &character[4]; pchar[5] = &character[5]; ? i hope thats wrong... thats allot to type for somthing so small :( Thank! ~SilverShalkin :rose:
-
Is it me, or does there seem to be a bubble of questions with long subjects and nothing of any merit in the actual body of the message.did you spell check that? ~SilverShalkin :rose:
-
experimenting... "to understand pointers more"this is my code: #include using namespace std; char *pchar[6]; char character[6] = "hello"; int main() { strcpy(pchar, &character); return 0; } that is "all" my code, no more no less. the problem accures on line: strcpy(pchar, &character); im not very sure on what this'll do, what i am trying to do is, have pchar point to the address of character. i thought that if there was more than one character i should use strcpy(), but im not very sure. how would i accomplish this? "see any problems, or better way of doing things, just note it :)" Thanks! ~SilverShalkin
-
pointer to an array... "char"Orbital^ wrote: Anyway you can not do *pID=SID because *pID is not a l-value so you have to use a function like memcopy ... or strcopy if it is a string that makes more sense! so everything dealing with arrays, do not set equal, yet, strcpy() and memcpy()? i'll look through some more things, and try it again! Thanks everybody! i alos will check out std::string :) ~SilverShalkin :rose:
-
pointer to an array... "char"ok, this is my code: char ID::SetID(char SID[11]) { char *pID[11]; char SSID[11]; pID = &SSID; *pID = SID; strcpy(&M_ID, SSID); return 0; } //i got my code to work with one character, now i want to make it work with more like 10 :) i have one problem "yet again" and it deals with the line: pID = &SSID; //i dont understand my error. this is the error: error C2440: '=' : cannot convert from 'char (*)[11]' to 'char *[11]' what does (*) mean, and: is there another way to declare a pointer to point to somthing? Thanks for your help! ~SilverShalkin
-
whats wrong witt this?well, i looked up some of my errors in msdn and it said that the main problem of the code is that the person is trying to set two seperate things equal to each other, like-a pointer and a non pointer, or a intiger and a character. one of the main problems as i was going through out figuering this out was... my header file held different info than my cpp, so it made a bunch on errors.... I think i got it, to the point that i wont come across the problem again, unless its a typo "which, as a experienced programmer know (theres always typos :) )" Thanks for your help! ~SilverShalkin :rose:
-
whats wrong witt this?i changed it to what you said, and now i got this error pop up: error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' what does it mean by parameter 1? thanks! ~SilverShalkin :rose:
-
whats wrong witt this?ok... so i would have to have a pointer on the second one like: strcpy(M_ID, *PID); *PID points to SID which is the intake of info for the function. or would i do... strcpy(M_ID, PID); //without derefrencing it? Thanks! ~SilverShalkin :rose:
-
whats wrong witt this?ok... my problem accures in this line of code: strcpy(M_ID, STID); error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' M_ID is a member of my class ID, and STID is a char created within the function that this code lies. i dont understand why it says char to * char because, non of them are pointers. thanks for your help! ~SilverShalkin
-
locating memory- easy(char[])thanks! i was using strcpy() but then switched over because things werent working... ill try it again. Any tutorials? Thanks again! ~SilverShalkin :rose:
-
locating memory- easy(char[])if you declare the amount of info that you want to store in a char like... char ID[10]; that would mean that id has 10 slots + \0; right? now, if i would want to print out all the info from char ID... wouldnt i just.. cout << ID;? and if you wrote: cout << ID[2]; you would get the third memory slot, right? why cant i set M_ID = ID? M_ID is [10] and so is ID. bool ID::SetID(char ID[10]) { M_ID = ID return true; } i get an error when i put this in, and the only way i get rid of it is if i make: ID[]; and within the [] i would have to have a number. but i want all of ID = M_ID.., what do i do? what do i put in the []? also... if there is a good tutorial that teaches how to compare data, and all the little detail of do what im trying to do, please make note of it. Thanks! ~SilverShalkin :rose: ps... I started this message like 1-2 hours ago, and kept jumping back to my code and trying new things... so if the message is unclear about my mainpoint "question" just tell me, and i will refrase it in a more understandable way :)
-
ok... quick and easy... cin.flush();ok... that makes more sense... cin.clear(); but is that all? the line works but the program comes acrros the same thing... after you insert the GPA of the student "GPA is a float" the program prints the name and the gpa, then it asks for the name again, but when you press enter after the name, the program atomatically inserts the previouse GPA. thanks again.. "If i figuere it out, ill post :)" ~SilverShalkin :rose:
-
ok... quick and easy... cin.flush();i asked a question refering to why my cin stopped working after the program had looped, my answer was cin.flush(); I applied that line to my code, and the program didnt reconize it,... if this is the way to reinitialize a cin for it works everytime the loop goes through, then why wont it work? is there a required header? painless see? thanks! ~SilverShalkin :rose:
-
having problems with cin "go figuere :)"ok... in this code... you dont have to worry where everything is being defined or what headers im using,... wheres my functions... this is just the main program... It all works the first time through, then, the cin stops working: int main() { for(;;)//main loop { gets(SName); cin >> SGPA; person.SetName(SName); person.SetGPA(SGPA); cout << person.GetName() << endl << endl; //print name that you just typed. for(int inc = 0;inc < NN;inc++) //print all names. { cout << Names[inc] << "\t" << GPAS[inc] << endl; } inc = 0; }//end main loop. return 0; } in the program is waits for input for the name of sombody... then it goes on to the next thing... which is my cin statment, asking for the float "GPA" of the persons name you put in. after the first time you run through the on going loop... your not able to insert a GPA, rather, for every new name you put in... it applies the original GPA to the names. Q~How do i reset my cin or get it to work everytime in the loop. set it to null? Thanks! ~SilverShalkin :rose: i have a fealling that it might not be the cin :(, but i'll see in a bit :)
-
Memory compareing with char'sdid you know joaquin is the name of my streat? your famous!!!! Thanks for the help again :) and again, and again :) its always appreciated ~SilverShalkin :rose:
-
Memory compareing with char'sJason Henderson wrote: strncpy(Names[NN], NName, 32); i put this in... but the , 32) doesnt work, but now the command works! so im not sure if i needed the 32.. hmmm :) Thanks for the help! ~SilverShalkin :rose:
-
Memory compareing with char'sill try it out... thanks! ~SilverShalkin :rose: