Skip to content

Instantly share code, notes, and snippets.

@dvtate
Created February 1, 2017 04:04
Show Gist options
  • Save dvtate/564040d9e9deb8308f8a4fcf90fa4284 to your computer and use it in GitHub Desktop.
Save dvtate/564040d9e9deb8308f8a4fcf90fa4284 to your computer and use it in GitHub Desktop.
:)
#include <iostream>
#include <string.h>
int main(int argc, char* args[]){
if (strcmp(args[1], "--version") == 0) {
std::cout <<"This is a ghetto echo function that reads in reverse.\n";
return 0;
} else if (strcmp(args[1], "--help") == 0) {
std::cout <<"Useage: echo [OPTION]... [STRING]...\n"
<<
}
for (size_t elem = 0; elem < argc; elem++)
std::cout <<args[elem] <<' ';
// -n flag means no terminating newline
if (args[1][0] != '-' && args[1][1] != 'n')
std::cout <<std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment