I have program that has the user entering the full path to the folder holding several datafiles.
for example So say the user enters:
\\psf\Home\Desktop\HealthScore\HealthScore\DataFiles
I need to change it within the program to:
\\psf\Home\Desktop\HealthScore\HealthScore\DataFiles\BT_1.txt
I've tried adding the string together with one a pointer, the other is an array and with both parts being pointers.
Here is a sample of my latest attempt:
char filepath[1000];
FILE* fp;
char BP1_ext [] = "\\BP1.txt";
printf("Enter the path to the file holding the data files:");
fflush(stdin);
scanf("%s", filepath);
//////////////////////BLOOD PRESSURE//////////////////////
if (bpSensors == 1)
{
filepath = (filepath + BP1_ext);
fp = fopen(filepath, "r");
if (fp == NULL)
{
puts("ERROR OPENING FILES");
exit(EXIT_FAILURE);
}
else
{
while (!feof(fp))
{
printf("\n\nREADING BP_1.txt...");
fgets(bp1_Line, 100, fp);
sscanf(bp1_Line, "%s\t%s\t%s", bp1_Val1, bp1_Val2, bp1_Val3);
printf("%s\t%s\t%s\n", bp1_Val1, bp1_Val2, bp1_Val3);
}
fclose(fp);
}
}