Hi, SwapSwae
Nice to see u r reply in the thread "going to particular folder".
Yeah u r right I am getting 99% every time and unable to get what I want...
Now today I got the code as u suggested and only one error in this code is it couldn't able to allocate sufficient memory allocation... How to give or know how much space it occupies..
The code goes like this...
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
#include <malloc.h>
FILE *fp,*fs;
int main()
{
//char name[8], command[20]="md ";
char path[8] ="E:\\abc";
char name[8];
// char drv;
// char abc[20] = "\";
printf("Enter absolute path for Directory to be created :"
scanf("%s",name);
strcat(name, ".txt"
strcat(path,"\\"
strcat(path, name);
printf ("The folder is.... %s\n", path);
fflush(stdin);
//system(command1);
//system(command);
fp = (char *) malloc(sizeof(char) * (strlen(path) + 5));
fp=fopen(path,"r"
if(fp==NULL)
{
printf("\nNo such file"
exit(1);
}
printf("\nFile opened successfully...."
return 1;
}
The above code is opeing the file successfully... but in in running the compiler is saying "unable to rea memory...." though I have given the malloc..
What could be the error...
Thanks in advance
Sridhar
Nice to see u r reply in the thread "going to particular folder".
Yeah u r right I am getting 99% every time and unable to get what I want...
Now today I got the code as u suggested and only one error in this code is it couldn't able to allocate sufficient memory allocation... How to give or know how much space it occupies..
The code goes like this...
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
#include <malloc.h>
FILE *fp,*fs;
int main()
{
//char name[8], command[20]="md ";
char path[8] ="E:\\abc";
char name[8];
// char drv;
// char abc[20] = "\";
printf("Enter absolute path for Directory to be created :"
scanf("%s",name);
strcat(name, ".txt"
strcat(path,"\\"
strcat(path, name);
printf ("The folder is.... %s\n", path);
fflush(stdin);
//system(command1);
//system(command);
fp = (char *) malloc(sizeof(char) * (strlen(path) + 5));
fp=fopen(path,"r"
if(fp==NULL)
{
printf("\nNo such file"
exit(1);
}
printf("\nFile opened successfully...."
return 1;
}
The above code is opeing the file successfully... but in in running the compiler is saying "unable to rea memory...." though I have given the malloc..
What could be the error...
Thanks in advance
Sridhar