How do I access a variable in a one C file from another?

I have two C files. I want to declare a variable in one, then be able to access it from another C file. My definition of the example string might not be perfect, but you get the idea.

//file1.c

char *hello="hello";

//file2.c

printf("%s",hello);

Answers


// file1.h
#ifndef FILE1_H
#define FILE1_H
extern char* hello;

#endif


// file1.c
// as before


// file2.c
#include "file1.h"
// the rest as before

Need Your Help

Having trouble with jQuery height auto-adjust

jquery sharepoint-2007 height positioning

I have a page in SharePoint that contains both a local and global content. For the local content, we use a customized editor web part (Telerik). For the global content, I had jQuery write the conte...