| |
| |
| |
|
Page: 1 2 3 4
Comments:
<0> when you do a free() what really happen?, what happen if i do free(p+10); (i did p=malloc 20 before); <1> usually something bad. <0> doenst free the the las 10 bytes? <1> no! <0> then how it know how many bytes must free? <0> got a table? <1> it knows to free as much as was allocated. you cannot free part of an allocation. <0> ok <0> my code is geting dirty <0> I read a file to fille a structure, the structure got a pointer, . so i m using my structure pointing to the bytes readed from the file. <0> with that i just do 1 malloc. <2> man this looks crappy http://www.rafb.net/paste/results/4lbjWm90.html <0> int myint = (u_short)-1; <2> HellMind thats just a place i stuff a number to test <1> any particular reason you are avoiding sprintf? <3> are pointers only used for arrays, dynamic memory allocation and p***ing by reference?
<1> the code ***umes that the letters are always adjacent, which isn't universally true. <1> [aG]Sociopat: are int's only used to hold int's? why does it do so little! <2> twkm well its all i can think of and i have no idea what EwIck was refering to <0> :P <0> c got any default hash function? <1> nope. <0> look mine http://www.rafb.net/paste/results/AAuvXJ26.html <2> twkm so is there a macro for conversion incase there not adjacent? <1> winkey: nope. most people make an array. <3> why cant the memory allocation functions return a value instead of a memory address? <1> they do return a value. a pointer value. <3> why? <1> why not? <3> because if you wanna free or to expand you just do &varname instead of varname itself <1> so? <3> so its less confusing <1> wrong. <3> there is virtually no use for pointers <3> at all <3> I cant find anything i can do with pointers that I cant do without <1> when i write code i *know* that foo(x) cannot possibly change x. <1> i know that bar(&x) probably will. <3> twkm : thats detached from anything I claimed or asked <1> *shrug* <1> c was designed in the days when type were mostly unknown, but were becoming of more importance. <3> so? <1> so it had a small number of types, each of which has specific applications. <3> give me an example <3> of something I can do with pointers <3> and cant do without <1> the standard increased the number of types. <1> i already did. if f() didn't take a pointer to int it would not be possible to change i. <3> thats it? <3> why calling it pointer? <1> because it sounds silly to call it a floop. <3> ok <3> then there is only one real use <1> the value points at something else, hence a pointer. <3> whats all the big noise about pointers then? <1> isn't that sufficient? <3> no <1> oh well. <3> iv'e heard people claiming <3> pointers are used to create dynamic data structures <3> and stuff <3> but they arent vital for it <1> they tend to be critical to it. <3> nop <2> [aG]Sociopat heres a use for you, does it take more resources to p*** to a function an array like int myarray[65535]; or would it take less with p***ing a pointer? <3> they dont <1> what if you don't know how long a string might be? you cannot use an array. you must use allocated storage, which depends on the notion of a pointer to the otherwise anonymous location of the storage. <1> winkey: since array's are p***ed by value, and the value of an array is a pointer to the first element, that isn't likely to be a useful question. <3> that depends on the notion of an address not of a pointer <3> and you can get to the address with &address <1> no, you think it is called address. <2> twkm good point <1> c calls it a pointer value. <2> think first i guess <3> lk <1> you'll be happy to know that the unary & operator is also called the address of operator. <2> twkm a structure then ;-)
<3> what about linked lists? <1> pointers tend to be useful there too, though if the upper limit on the number of nodes is known and small enough you need not use pointers. <1> most likely anywhere you want to say "address" you really mean "pointer value". <2> twkm wouldn't that take up alot of space if your note using all the "nodes"? <1> if you feel you mean address then you aren't thinking in c yet. <3> why would i wanna save an address (in a pointer)? <3> I can always do &bla to get the address... <1> winkey: sure, which is why the upper limit would have to be known and "small enough". <1> [aG]Sociopat: what if you cannot? <3> when cant I? <1> malloc's return value cannot be &'d. <3> why not? <1> if i p*** a pointer value to you, you no longer know the name of the thing. <2> what about the math? http://www.rafb.net/paste/results/sGKU8Y98.html <3> so thats the reason it returns the location? <3> because it cant reference the value? <3> in any other way? <1> [aG]Sociopat: because how do you use & with the returned value? &p would be the address of the thing named p, not the value it holds. <3> I didnt get your last sentence <3> rephrase <3> twkm? <2> [aG]Sociopat remeber that for looped i pasted <2> for (*dst++ = *src++); <2> thats basicly strcpy() write up one without pointers then paste it here http://www.rafb.net/paste/ then paste us the url <1> sorry, i've some family things to do. if you are still wondering when i get back i'll take it up again. <3> let me do some thinking <3> if the allocation function returns a value, what do I do with it? <3> I cant put it anywhere <3> because what I got is the value not the allocated memory <3> and the allocated place is lost actually <2> it returns void * <3> I get it <3> but im too stupid to soak it <3> int x is a variable, that is a cell in memory, &x is the address (the pointer value) <2> char *mystring = NULL; if (!(mystring = malloc(50)) {exit(EXIT_FAILURE);} <3> and x is the value in that cell <3> its all about referencing <3> is it possible returning the composition of address and reference of a variable? <2> you program in java? <3> im leanring <3> learning <2> or some other similar lang? <2> address and reference? <3> yes <3> int x <3> &x is address x is value <2> int x = 4; <3> is it possible returning x <2> int *y = &x; <2> y is a pointer <2> the pointer points at x <2> because we told it to here int *y = &x; <2> char test[] = "hi there"; char *x = test char *y = x + 3; printf ("%s\n", x); printf("%s\n", y); <2> what does the first printf print? <2> what does the second one print? <3> it prints t <3> dosent it? <2> no <2> the firts one prints hi there <3> oho <2> the second one prints there <2> %s is a string <3> but x points to test <3> as a whole <3> it prints hi there completley it dosent stop before there <3> it prints hi there there <2> x points to "hi there" <2> so does test <2> in a way thats nox exactly correct but close <2> string literals are given a place in memory <2> char *y = x + 3; and char *y = x[3]; have the same result <2> erm no <2> sorry i am wrong <3> x[3] is a value tho
Return to
#c or Go to some related
logs:
feujworld hotmail #linux bagdasch #mirc #linux backtrack disable nopcmcia
www.vreausafut gigaboob #linuxhelp #MissKitten
|
|