Code:
#include <stdio.h>
/* #iclude <conio.h> */
#include <string.h>
#include "stack.h"
/* void main()*/
int main()
{
/* clrscr(); */
char str[1500];
char file[10];
char sfile[10];
int x;
FILE *fp1, *fp2;
printf("Enter filename:");
/* gets(file); */
fgets(file, sizeof(file), stdin);
fp1=fopen(file,"r");
printf("Save to:");
/* gets(sfile); */
fgets(file, sizeof(sfile), stdin);
fp2=fopen(sfile,"w");
if(fgetc(str, sizeof(str), fp1)!=NULL)
{
/* You just a single char here, whats up to the rest of them in the file */
fputs(str,fp2);
printf("Content is:\n %s", str);
}
else
printf("cannot open file!!!");
int y=strlen(str);
for(i=0;i<y;i++)
stach->push(str[i]);
printf("The reversed content is:");
for(int i=0;i<y;i++)
/* cout<<stack->pop(i); // This is a C++ standard dont use this in C */
printf("%c",stack->pop(i));
fclose(fp1);
fclose(fp2);
/* getch(); */
getchar();
return 0;
}
ssharish2005