473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 12661
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

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

Similar topics

22
by: Wynand Winterbach | last post by:
I think every C programmer can relate to the frustrations that malloc allocated arrays bring. In particular, I've always found the fact that the size of an array must be stored separately to be a...
19
by: junky_fellow | last post by:
Can the size of pointer variables of different type may be different on a particular architecture. For eg. Can the sizeof (char *) be different from sizeof(int *) or sizeof (void *) ? What...
5
by: nmtoan | last post by:
Hi, I could not find any answer to this simple question of mine. Suppose I have to write a program, the main parts of it are as follows: #include <blahblah.h> struct {
6
by: Laurent | last post by:
Hello, This is probably a dumb question, but I just would like to understand how the C# compiler computes the size of the managed structure or classes. I'm working on this class: public...
4
by: taskswap | last post by:
I'm converting an application that relies heavily on a binary network protocol. Within this protocol are a lot of byte arrays of character data, like: public unsafe struct MsgAddEntry {...
8
by: redefined.horizons | last post by:
I would like to have an array declaration where the size of the array is dependent on a variable. Something like this: /* Store the desired size of the array in a variable named "array_size". */...
10
by: Roman Mashak | last post by:
Hello, All! I've met the code containing this kind of structure: typedef struct cmd { unsigned int Cmd; unsigned int Code; unsigned int Data; } CMD;
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
15
by: kris | last post by:
Hi I am writing a small program where I need to obtain the actual size of a structure. The programm is as follows struct abc { int j; char k; int i; }*a;
24
by: Rob Hoelz | last post by:
Hello everyone, I'm working on a hashtable-based dictionary implementation in C, and it uses void pointers for data storage, naturally. However, since one of the data types I will be using it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.