1

I'm trying to input strings in my C structure but it says "warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]" I used to code in Dev-c ++ and I'm practicing at GCC does anyone can help me how to do it.

here is my code: payroll.c

#include<stdio.h>
#include"payroll.h"

void readName(p payroll[], int size){

fgets("%s",&payroll[size].name.first);


}

and in my payroll.h

struct namerec{

    char first[15];
    char middle[15];
    char last[15];

};

typedef struct payrecord{
    int id;
    struct namerec name;
    float hours,rate;
    float regular,overtime;
    float gross, tax_whh, net;
}p;

void readName(p payroll[], int size);
void printName(p payroll[], int size);
void printSummary(double gross, double tax);
void readRecord(p payroll[], int n);
void printRecord(p payroll[], int n);
double calcRecords(p payroll[], int n,double *taxptr);
DumbDrw
  • 35
  • 9
  • 2
    Note`fgets()`takes three arguments. (and `gets()` was removed from the library, so it should not exist) – wildplasser Aug 16 '17 at 13:17
  • 3
    `fgets("%s",&payroll[size].name.first);` --> `scanf("%14s", payroll[size-1].name.first);` ? – BLUEPIXY Aug 16 '17 at 13:18
  • 1
    Just a style suggestion, but you should aim for consistent and meaningful names for variables and arguments. `size` isn't good when you are referring to an index, and half your functions seem to use `n` for the same purpose. – Retired Ninja Aug 16 '17 at 13:24
  • `gets` does not exist in stdio.h, it has been removed from the standard. That's why you get the _implicit declaration_ warning – Jabberwocky Aug 16 '17 at 13:24
  • yeah my code is not complete yet coz i was trying the scanf/gets first before putting loop for the size thanks guys its really hard to learn in ubuntu tho but i need to learn haha – DumbDrw Aug 16 '17 at 13:27
  • Because the gets() function was flagged as obsolete 18 years ago, and completely removed 6 years ago. It does no longer exist in standard C. – Lundin Aug 16 '17 at 13:30

0 Answers0