hello all,

actually i am working on sipmle work inwhich i need to import one file whic is of .hex extension, so i need to import a file which should be exactly same name with .hex extension. how should i implement such that it should take that file name with .hex extension.

So what is your problem?

1. Reading files
2. Converting filenames

You'll need to be more specific.

>> i need to import one file whic is of .hex extension

file.hex <- one file

>> so i need to import a file which should be exactly same name with .hex extension

folder1 / file.hex
folder2 / file.hex <- Exactly the same name

>> how should i implement such that it should take that file name with .hex extension

#include <stdio.h>
#include <string.h>

int main() {
  char hexFile1[] = "folder1/file.hex";
  char hexFile2[256]; /* Take that file name with .hex extension into hexFile2 */

  strcpy(hexFile2, hexFile1);

  FILE * pFile;
  pFile = fopen (hexFile2,"r");

  // <- import here

  fclose(pFile);
  
  return 0;
}

This is the absolute best interpretation I could think of for your question.

Either chdir into folder2 and open file.hex, or substitute folder2 for folder1 in the path string, and open that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.