Richard94 Richard94 - 9 months ago 47
C Question

stuck with structures, gets and puts

I stuck with this code.

I saved this header file (header.h) at the same folder where I saved the main.c

struct user{
int userID;
char firstName[30];
char surName[30];

this is my main.c file which
belongs to.

#include <stdio.h>
#include <header.h>

int main()
struct user Richard;
struct user Kelvin;
struct user Ann;

Richard.userID = 1;
Kelvin.userID = 2;
Ann.userID = 3;

puts("Enter the first name of user 1");
puts("Enter the Surname of user 1");

puts("\n\nEnter the first name of user 2");
puts("Enter the Surname of user 2");

puts("\n\nEnter the first name of user 3");
puts("Enter the Surname of user 3");

printf("\n\n user 1 ID is %d \n", Richard.userID);
printf("user 1 full name is %s %s. \n\n", Richard.firstname,Richard.surname);
printf("user 2 ID is %d \n", Kelvin.userID);
printf("user 2 full name is %s %s. \n\n", Kelvin.firstname,Kelvin.surname);
printf("user 3 ID is %d \n", Ann.userID);
printf("user 3 full name is %s %s. \n", Ann.firstname,Ann.surname);
return 0;

I use CodeBlocks. This code doesn't run. When I run this code the build log says
fatal error: header.h: No such file or directory
#include <header.h>

I can't find the bug on this code.

Answer Source

In your main.c code,
Replace #include <header.h> with #include "header.h"

In your header.c code,
Replace surName with surname
Replace firstName with firstname