#include <stdio.h>
//#include <stdlib.h> //for system pause
//USAGE (in DOS): dir blah | yourProgramName > outFile.txt
// (use /b for JUST file and folder names)
// (use /b /ad for JUST folder names)
void printsln(char *s) {printf("%s
", s);}
void error(char *s){printsln(s); exit(1);}
bool ngets(char *s, int n) {
int i = 0;
char c;
c = getchar();
if (c==EOF) {s[i] = 0; return false;}
while(c!='
'){
if(i>=n) error("input stream overflowed buffer");
s[i++] = (char)c;
c = getchar();
}
s[i] = 0;
return true;
}
int main(int argc, char *argv[])
{
char s[10000]; //note: possible (in theory) security hole
while(ngets(s, 10000)) { //security hole closed.
printf("/new/%s
", s, s); //TWEAK THIS LINE!!!
}
//system("pause");
return 0;
}
C Console Scripting Framework
Leave a Reply
You must be logged in to post a comment.