files invlove character stacking
if the stack is not used, i tried to use a stack to read the content of the file and displays the content in reversed
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "stack.h"
void main()
{
clrscr();
char str[1500];
char file[10];
char sfile[10];
int x;
FILE *fp1, *fp2;
printf("Enter filename:");
gets(file);
fp1=fopen(file,"r");
printf("Save to:");
gets(sfile);
fp2=fopen(sfile,"w");
if(fgetc(str, sizeof(str), fp1)!=NULL)
{
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);
}
fclose(fp1);
fclose(fp2);
getch();
}
by using stack.h in a turbo c library...the improper typedef happens on push and pop stack...what are things do you suggests in this code?