Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all! I am running Linux C on my MacBook Pro and cannot get the struct command to work properly. Below is the basic code and RUNTIME errors I am ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    2

    struct command, run time errors

    Hi all!
    I am running Linux C on my MacBook Pro and cannot get the struct command to work properly. Below is the basic code and RUNTIME errors I am getting. Any feedback on this would be GREATLY appreciated.

    Thanks,

    #include <stdio.h>
    typedef struct Payroll
    {
    int empNumber;
    char name[25];
    double hours;
    double payRate;
    double grossPay;
    } Payroll;

    int main()
    {
    struct PayRoll employee;

    // Get the employee's number
    printf("Enter the employee number: ");
    scanf("%d",&employee.empNumber);
    printf("%d",&employee.empNumber);
    }

    john-crispin-4s-macbook:~ johncrispin1$ gcc -o RecordExample RecordExample.c
    john-crispin-4s-macbook:~ johncrispin1$ ./RecordExample.c
    ./RecordExample.c: line 4: typedef: command not found
    ./RecordExample.c: line 11: syntax error near unexpected token `Payroll'
    ./RecordExample.c: line 11: `} Payroll;'
    john-crispin-4s-macbook:~ johncrispin1$

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    the ./ attempts to execute that source file as a bash script, not a binary executable

  3. #3
    Just Joined!
    Join Date
    Dec 2008
    Posts
    2

    run command

    Thanks. I realized after I submitted the post that I using the .c extension on the run command. After I took it off it ran fine. Thanks again for the reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...