Search
 
SCRIPT & CODE EXAMPLE
 

C

struct

#include <stdio.h>

main () {
	struct person {
		char[] name;
		int age;
	}
}
Comment

struct in struct

// C program to implement
// the above approach
#include <stdio.h>
#include <string.h>

// Declaration of the
// dependent structure
struct Employee
{
  int employee_id;
  char name[20];
  int salary;
};

// Declaration of the
// Outer structure
struct Organisation
{
  char organisation_name[20];
  char org_number[20];

  // Dependent structure is used
  // as a member inside the main
  // structure for implementing
  // nested structure
  struct Employee emp;
};

// Driver code
int main()
{
  // Structure variable
  struct Organisation org;

  // Print the size of organisation
  // structure
  printf("The size of structure organisation : %ld
",
          sizeof(org));

  org.emp.employee_id = 101;
  strcpy(org.emp.name, "Robert");
  org.emp.salary = 400000;
  strcpy(org.organisation_name,
          "GeeksforGeeks");
  strcpy(org.org_number, "GFG123768");


  // Printing the details
  printf("Organisation Name : %s
",
          org.organisation_name);
  printf("Organisation Number : %s
",
          org.org_number);
  printf("Employee id : %d
",
          org.emp.employee_id);
  printf("Employee name : %s
",
          org.emp.name);
  printf("Employee Salary : %d
",
          org.emp.salary);
}
Comment

struct

public struct S : IDisposable
    {
        private bool dispose;
        public void Dispose()
        {
            dispose = true;
        }
        public bool GetDispose()
        {
            return dispose;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var s = new S(); 
            using (s)
            {
                Console.WriteLine(s.GetDispose());
            }
            Console.WriteLine(s.GetDispose());
        }
        /*result
         False
        False
         */
    }
Comment

PREVIOUS NEXT
Code Example
C :: What should main() return in C? 
C :: finding characters in string 
C :: %g and %e in c 
C :: atoi string to int 
C :: check for duplicates c 
C :: logical operators in c 
C :: pointer in c 
C :: how to read and write to fiel n c 
C :: typedef c 
C :: deleting a word with copy fuction c code 
C :: pipe system call 
C :: type cast in c 
C :: metw.cc 
C :: C++ How to use enums for flags? 
C :: c program for fibonacci series 
C :: how to define pi in c 
C :: BST or NOT ?? 
C :: binary operations on structs C 
C :: input multipal data types 
C :: Multi Select with icons htm; 
C :: pre-commit configuration 
C :: How to open terminal cs50 ide 
C :: find a substring within a string in c and return the index 
C :: write a ppm image 
C :: #include <stdio.h int main() { int x = 10, *y, **z; y = &x; z = &y; printf(""%d %d %d"", *y, **z, *(*z)); return 0; } 
C :: The closest in between 
C :: Sampoo C programming 
C :: how to check where the last char is in a string c 
C :: how can i show ant text by onclick 
Dart :: decode, encode base64 dart 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =