B
BHARAT
Hi I am a little bit new to C's advanced topics:
I have Turbo C and I wrote a simple program to write data to file:
#include<stdio.h>
#include<dir.h>
#include<conio.h>
#include<stdlib.h>
// program to write a long string to a file
void main()
{ FILE *pt;
char *b;
chdir("d:\\test");
pt=fopen("bharat.text","w");
printf("ENter ur message ");
scanf(" %[^\n]",b);
fprintf(pt," %s",b);
fclose(pt);
getch();
}
Every thing works fine with this code. But there is a problem. Suppose
I wish to enter a
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa......................................................................................
nmnmnnhjjjhjhjhjhujhjhjhjh hjhjhj hjhjhjhhhjh ........
jhujhjhjhjhjh22312 444545 jjkjkjkjkjkj" , then the program fails. It
doesn't allows to take more input? Can you tell why is it happening
although I am using Pointers? How do I solve this problem?
I have Turbo C and I wrote a simple program to write data to file:
#include<stdio.h>
#include<dir.h>
#include<conio.h>
#include<stdlib.h>
// program to write a long string to a file
void main()
{ FILE *pt;
char *b;
chdir("d:\\test");
pt=fopen("bharat.text","w");
printf("ENter ur message ");
scanf(" %[^\n]",b);
fprintf(pt," %s",b);
fclose(pt);
getch();
}
Every thing works fine with this code. But there is a problem. Suppose
I wish to enter a
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa......................................................................................
nmnmnnhjjjhjhjhjhujhjhjhjh hjhjhj hjhjhjhhhjh ........
jhujhjhjhjhjh22312 444545 jjkjkjkjkjkj" , then the program fails. It
doesn't allows to take more input? Can you tell why is it happening
although I am using Pointers? How do I solve this problem?