Thread: struct

  1. #1
    Registered User
    Join Date
    Nov 2020


    Hello guys,
    I want to create a struct that lets say is the employee and contains some values for the employee
    If i want to create n employees(The user says how many are the employees of the company) how do i do it?
    Keep in mind i want to compare the values betweeen the employees

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    // one of them
    struct employee {
      char name[10];
      // anything else you want to save
    // many of them
    struct employee employees[100];
    > The user says how many are the employees of the company
    struct employee *employees = malloc( howmany * sizeof(*employees));
    In either case, you start with
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2019, 07:51 AM
  2. typedef struct vs struct declaration error in code
    By shaswat in forum C Programming
    Replies: 3
    Last Post: 07-25-2016, 06:45 AM
  3. Using data struct and I got an error in struct function
    By abrofunky in forum C++ Programming
    Replies: 4
    Last Post: 02-18-2012, 07:47 PM
  4. Replies: 1
    Last Post: 05-12-2011, 01:02 AM
  5. struct holding data inside a linked list struct
    By icestorm in forum C Programming
    Replies: 2
    Last Post: 10-06-2009, 12:49 PM

Tags for this Thread