/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include "test.h"
#include "shared.h"
int main()
{
printf("Hello World\n");
toOne();
printf("testVar: %d\n", testVar);
printTestStruct();
initTestStruct("New name", 3141592);
printTestStruct();
}
#include "test.h"
#include <stdio.h>
#include <string.h>
int testVar = 0;
nameId testStruct = { "testStruct", 42 };
void initTestStruct(const char *name, long id)
{
strncpy(testStruct.name, name, sizeof(testStruct.name));
testStruct.id = id;
}
void printTestStruct()
{
printf("testStruct name: %s\n", testStruct.name);
printf("testStruct id: %ld\n", testStruct.id);
}
void toOne() {
testVar = 1;
}
#ifndef TEST_H
#define TEST_H
#include "shared.h"
void toOne();
void initTestStruct(const char *name, long id);
void printTestStruct();
#endif /*TEST_H*/
#ifndef SHARED_H
#define SHARED_H
typedef struct {
char name[32];
long id;
} nameId;
extern nameId testStruct;
extern int testVar;
#endif /*SHARED_H*/