473,396 Members | 2,061 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,396 software developers and data experts.

problem with nested structures

3
I having a nested structures which are referenced with pointer variables
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. struct test
  3. {
  4.   int i;
  5.   char *mytest;
  6. };
  7. struct sample
  8. {
  9.   int k;
  10.   struct test *test1;
  11. };
  12. int main()
  13. {
  14.   struct sample *mysample;
  15.   printf("Inside main method \n\n");
  16.   mysample->k=0;
  17.   mysample->test1->i=1;  // It's throws segmentation fault error at this point how to access this variable.
  18.   printf("the value of the k is  %d \n\n",mysample->k);
  19.   //  printf("the value of the k is  %d \n\n",mysample->test->i);
  20.   return 0;
  21. }
  22.  
please help me as soon as possible
Mar 19 '07 #1
2 2441
r035198x
13,262 8TB
Moved to C++ forum.
Mar 19 '07 #2
horace1
1,510 Expert 1GB
you need to point the pointer sat some objects, e.g.
Expand|Select|Wrap|Line Numbers
  1.  struct sample s;
  2.   struct sample *mysample=&s;
  3.   printf("Inside main method \n\n");
  4.   mysample->k=0;
  5.   struct test t;
  6.   mysample->test1=&t;  
  7.   mysample->test1->i=1;  // It's throws segmentation fault error at this point how to access this variable.
  8.  
Mar 19 '07 #3

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

Similar topics

25
by: chad | last post by:
I am writing a program to do some reliability calculations that require several nested for-loops. However, I believe that as the models become more complex, the number of required for-loops will...
9
by: OKB (not okblacke) | last post by:
For a variety of reasons, I'm interested in putting together some code that will allow me to created structures out of nested classes, something like: class class1: def methA(self): print...
29
by: Joseph Haig | last post by:
I am trying to use descriptive lists, <DL>, as shown in <http://www.maths.man.ac.uk/~jhaig/tmp/test.html> with a style sheet at <http://www.maths.man.ac.uk/~jhaig/tmp/default-2.css>. With Mozilla...
11
by: Alfonso Morra | last post by:
Hi, I have the ff data types : typedef enum { VAL_LONG , VAL_DOUBLE , VAL_STRING , VAL_DATASET }ValueTypeEnum ;
7
by: Nikos Mitas | last post by:
I have the following structure: struct DIRECTORY{ char nameDir; struct DIRECTORY *parent; int numSubDir; struct DIRECTORY *subDir; };
25
by: GY2 | last post by:
I writing some documentation and I want to describe a common code structure which is used to step through all the items in a collection (e.g. each file in a subdirectory) while applying more and...
3
by: mrquan83 | last post by:
I'm using Nini from http://nini.sourceforge.net to read and write XML files. I'm having trouble creating nested 'configs' (Sections) however. This is a sample of my code.... ----- vb.net...
25
by: bweaverusenet | last post by:
Hi. I am trying to get some javascript to work in IE6, from the address line. It works in Firefox and, I believe, IE7. It appears that with some number of nested structures, the code does not...
3
by: Amit_Basnak | last post by:
Dear Friends I have the follwoing function "tss_fe_get_own_info" which has the arguments as shows below tss_fe_get_own_info(char *user_id, tss_user_profile_t **p_buf_UserSecInfo, error_status_t...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.