I wrote this K-Journal program out of complete boredom, when I compile it under C++ Specs it works, when I compile under C it does not work, can someone explain why and if possible explain what I should do so I can compile it under C
Code:
/*
* k-journal.c
* A console based Journal
Copyright (C) 2002 Lucas Campbell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
int main()
{
char str[9999], retime[25];
time_t tp;
tp = time(NULL);
printf(" _ _\n");
printf(" | | / /\n");
printf(" | | / /\n");
printf(" | | / /\n");
printf(" | | / /\n");
printf(" | ^ / JOURNAL\n");
printf(" | |^ \\\n");
printf(" | | \\ \\\n");
printf(" | | \\ \\\n");
printf(" |_| \\_\\\n");
printf("+---------------------------+\n");
printf("Enter your text: ");
FILE *fp = fopen("k-journal.txt","a");
gets(str);
if(!strcmp("l",str))
fprintf(fp,"Blank (l)");
else
fprintf(fp,str);
fprintf(fp,"\n");
strcpy(retime,ctime(&tp));
fprintf(fp,retime);
printf("%s\n\n ",retime);
fclose(fp);
return 0;
}