0

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.

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Martin B
0

So what is your problem?

1. Reading files
2. Converting filenames

You'll need to be more specific.

0

>> 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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.