By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,789 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,789 IT Pros & Developers. It's quick & easy.

size of structure pointer

P: 2
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
Share this Question
Share on Google+
4 Replies

sicarie
Expert Mod 2.5K+
P: 4,677
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
Expert Mod 5K+
P: 9,197
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

P: 2
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
Expert Mod 5K+
P: 9,197
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.