Hi, SwapSwae,
U have got the problem... and the problem is.. as u explained...
When first time prog runs, the path is "C:\\SwapC" and then we concatenate the name of file to it making it look something like this "C:\\SwapC\\abc.txt", Now when u return bk to the same u already have "C:\\SwapC\\abc.txt" in path and now if u concatenate another name to it, this will make path look like "C:\\SwapC\\abc.txt\xyz.txt". If this is what u r asking then I'll say u have not read my mail clearly, I said declare them before while and assign values inside while what i meant is :
char path[18];
char name[8];
while(true)
{
path="C:\\SwapC";
//accept name;
strcat(path,name);
...
...
}
In the same way I have created the while loop and after while loop I have initialised the variable path and it is giving error....
the code is..
# 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[18];
char name[8];
char cont = 'y';
// char drv;
// char abc[20] = "\";
while(cont)
{
path = "E:\\abc";
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=fopen(path,"r"
if(fp==NULL)
{
printf("\nNo such file"
exit(1);
}
printf("\nFile opened successfully...."
cont = 'n';
}
return 1;
}
The error message is...
error C2440: '=' : cannot convert from 'char [7]' to 'char [18]'
There is no context in which this conversion is possible
Thanks in advance
Sridhar
U have got the problem... and the problem is.. as u explained...
When first time prog runs, the path is "C:\\SwapC" and then we concatenate the name of file to it making it look something like this "C:\\SwapC\\abc.txt", Now when u return bk to the same u already have "C:\\SwapC\\abc.txt" in path and now if u concatenate another name to it, this will make path look like "C:\\SwapC\\abc.txt\xyz.txt". If this is what u r asking then I'll say u have not read my mail clearly, I said declare them before while and assign values inside while what i meant is :
char path[18];
char name[8];
while(true)
{
path="C:\\SwapC";
//accept name;
strcat(path,name);
...
...
}
In the same way I have created the while loop and after while loop I have initialised the variable path and it is giving error....
the code is..
# 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[18];
char name[8];
char cont = 'y';
// char drv;
// char abc[20] = "\";
while(cont)
{
path = "E:\\abc";
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=fopen(path,"r"
if(fp==NULL)
{
printf("\nNo such file"
exit(1);
}
printf("\nFile opened successfully...."
cont = 'n';
}
return 1;
}
The error message is...
error C2440: '=' : cannot convert from 'char [7]' to 'char [18]'
There is no context in which this conversion is possible
Thanks in advance
Sridhar