GMS Linux: start?
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
TARGET = echo
|
||||
SRCS = echo.c
|
||||
CC = gcc
|
||||
CFLAGS = -static -Wall
|
||||
|
||||
OUT_BIN ?= $(TARGET)
|
||||
|
||||
all: $(OUT_BIN)
|
||||
|
||||
$(OUT_BIN): $(SRCS)
|
||||
@echo " [CC] Compiling to $(OUT_BIN)..."
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int start_index = 1;
|
||||
int no_newline = 0;
|
||||
|
||||
if (argc > 1 && strcmp(argv[1], "-n") == 0) {
|
||||
no_newline = 1;
|
||||
start_index = 2;
|
||||
}
|
||||
|
||||
for (int i = start_index; i < argc; i++) {
|
||||
printf("%s", argv[i]);
|
||||
if (i < argc - 1) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if (!no_newline) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user