Just started to learn Linux under the C language development, previously only in Windows to write a simple C language code, so the linux below the C language to write inadvertently understand, these days to see the relevant articles, finally have a smattering.
First Open the Life Terminal (ALT+CTRL+T), with vim to write three files main.c, STACK.C, stack.h
Main.c
#include <stdio.h>
#include "Stack.h"
void Main ()
{
int elem;
Stack stack;
Push (&stack, 1);
POPs (&stack, &elem);
}
Stack.h
typedef struct STACK {
int *base;
int top;
}stack;
extern void push (Stack *stack, int elem);
extern void POPs (Stack *stack, int *elem);
Stack.c
#include <stdio.h>
#include "Stack.h"
void push (Stack *stack, int elem)
{
printf ("This is Push function\n");
}
void POPs (Stack *stack, int *elem)
{
printf ("This is pop function\n");
}
All three files are under the same folder, and you can use the command: GCC main.c stack.c stack.h-o Mian compiles directly on the command line, but in order to learn to use makefile write a file for compiling
Makefile File:
MAIN:MAIN.O STACK.O
GCC MAIN.O stack.o-o Main
MAIN.O:MAIN.C stack.h
Gcc-c MAIN.C
STACK.O:STACK.C stack.h
Gcc-c STACK.C
This is done directly in the terminal to run make can be compiled ...
If the compiled file is not under the same folder, specify the path to the source file in the makefile file ...
Recommended Reading :
C + + implicit class type conversion implicit Class-type conversions http://www.linuxidc.com/Linux/2013-01/78071.htm
An analysis of C-language variable-length arrays http://www.linuxidc.com/Linux/2013-07/86997.htm
C language needs to pay attention to the problem http://www.linuxidc.com/Linux/2013-05/84301.htm
The use of C language bit domain and its attention point http://www.linuxidc.com/Linux/2013-07/87027.htm
Simple for loop and floating-point variable http://www.linuxidc.com/Linux/2013-08/88514.htm in C language
C language from getting started to mastering. (Wang Di, Han Xu). [PDF] + DVD video disc file http://www.linuxidc.com/linux/2013-10/91775.htm