469,602 Members | 1,741 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

size of structure pointer

plz check following code pMe i an structure pointer,in which char *linewisechar
is made.
pMe->linewisechar=(pMe->newcchar+STRLEN(pMe->newcchar)-1);

here i am assigning adress of last character of string pMe->newcchar to
pMe->linewisechar.

now in else part i am assignig
linewisechar=pMe->linewisechar;
linewisechar is local char * variable.

problem lies in while loop wt should be the value of n there i cant give it ++ coz then its incrementing only one char to it,so tht it point to next value in (pMe->newcchar+i-1);



if(currentline !=form_cursor->lines)
{
pMe->linewisechar=(pMe->newcchar+i-1);
else
{
linewisechar=pMe->linewisechar;
while ((*linewisechar)!='\0')
{
pMe->arr[k]=*(linewisechar);
linewisechar+=(n);
k++;
}

}
Jan 3 '08 #1
4 12225
sicarie
4,677 Expert Mod 4TB
Are you asking the size of the structure? (Which would probably be a bit over the size of all the datatypes and pointers to keep track of them) Or the size of a pointer to that structure (which is just the size of a pointer - a memory location).
Jan 3 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
The "size of a structure pointer" refers to the sizeof the struct variable the pointer points at. When you increment a structure pointer, the address in the pointer is incremented by the sizeof the struct.

Sometimes you read: "a pointer is as big as the object it points at". Means the same as above.

Of course, the pointer itself is only large enough to hold an address making all pointers exactly the same size.
Jan 3 '08 #3
The "size of a structure pointer" refers to the sizeof the struct variable the pointer points at. When you increment a structure pointer, the address in the pointer is incremented by the sizeof the struct.

Sometimes you read: "a pointer is as big as the object it points at". Means the same as above.

Of course, the pointer itself is only large enough to hold an address making all pointers exactly the same size.

thanks for all uor replys... i think i am not able to put my question properly any how the problem lies in the fact tht

pMe->linewisechar and pMe->newcchar

pMe is structure pointer in which linewisechar and newchar are declared as
char * . then in fun1() i assigned

pMe->linewisechar= pMe->newcchar+strlen(pMe->newcchar)-1 ;

which means i hav assigned to pMe->linewisechar address of last character of
string pMe->newcchar

but in my fun2() i have added one new character to string pMe->newcchar
but pMe->linewisechar ++ is not pointing to it .


can any one explain this concept

regards
Jan 4 '08 #4
weaknessforcats
9,208 Expert Mod 8TB
if(currentline !=form_cursor->lines)
{
pMe->linewisechar=(pMe->newcchar+i-1);
else
{
linewisechar=pMe->linewisechar;
while ((*linewisechar)!='\0')
{
pMe->arr[k]=*(linewisechar);
linewisechar+=(n); <<<<<<<<<<<<<<<<<<<<<
k++;
}

}
What is this n?? It better be 1.
Jan 4 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

22 posts views Thread by Wynand Winterbach | last post: by
19 posts views Thread by junky_fellow | last post: by
6 posts views Thread by Laurent | last post: by
8 posts views Thread by redefined.horizons | last post: by
10 posts views Thread by Roman Mashak | last post: by
15 posts views Thread by kris | last post: by
24 posts views Thread by Rob Hoelz | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.