I am running this code in Windows 7 it compiles and runs fine, but it does not create the reports.log file. I have run the code in Ubuntu and it works fine. Can anyone help figure out what I need to change to make it create the file. Thank you for your help. Code: /*includes*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> //prototypes char* now(); int main() { //local variables char comment[80]; char cmd[120]; fgets(comment, 80, stdin); sprintf(cmd, "echo %s %s >> reports.log", comment, now()); system(cmd); return 0; } /************************************************************************ * FUNCTION: FunctionName() * DESCRIPTION: Displays the parking lot status at the beginning of * the day * INPUT: * Parameters: aStack - this is the car stack * vanStack - this is the van stack * * File: N/A * * OUTPUT: * Return Value: N/A * * Parameters: N/A * * File: N/A * * * CALLS TO: N/A ************************************************************************/ char* now() { time_t t; time (&t); return asctime(localtime (&t)); }
Are you sure the file wasn't created at all? It's likely to have been created where you don't expect it. Try "dir/s c:\reports.log" and repeat for all drives on your system - that'll find it if it's there.