Executable file generation in Linux system
C language executable file generation example:
Generating an executable can include:
Writing Programs in C Language under Linux
open a file
$vim sssr.c
enter a program
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int a,guess=0,count=0;
srand((unsigned)time(NULL));
a=rand()%100;
printf("Bulls and Cows\n");
printf("You have five chances\nGood luck!\n");
printf("Please enter the number you guess\n:");
while(guess!=a&&count<=5)
{
scanf("%d",&guess);
if(guess<0)
{
break;
}
if(guess==a)
{
printf("You are right!\n");
count++;
}
else if(guess<a)
{
printf("Too small!\n");
count++
}
else
{
printf("Too big!\n");
count++;
}
}
printf("%d\n",a);
return 0;
}
Image example:
close the file and save
ESC
:wq
Compile the file
$gcc -c sssr.c -o sssr.o
link the file
$gcc -o sssr.exe sssr.o
execute executable
$./sssr.exe
Program running results show: