1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/utils/echo.cpp

25 lines
405 B
C++
Raw Normal View History

2011-11-25 18:54:17 -05:00
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
int startfrom = 1;
bool trailingnewline = true;
if ( 1 < argc && strcmp(argv[1], "-n") == 0 )
{
trailingnewline = false;
startfrom = 2;
}
const char* prefix = "";
for ( int i = startfrom; i < argc; i++ )
{
printf("%s%s", prefix, argv[i]);
prefix = " ";
}
if ( trailingnewline ) { printf("\n"); }
return 0;
}