0

Im using X code to develop a C++ algorithm. there i want to read a bmp file(testinp.bmp) to do that i have used following code. but it didnt work .and please help me.Thank you in advance for any help you can provide.

char inpfile[256]   = "testinp.bmp";


void fileReading(void)
{
    fprintf(stderr,">>> File Initializing <<<\n");

    fprintf(stderr, "Input File: %s\n\tReading...", inpfile);

    ReadBmp(inpfile, &inp);
fprintf(stderr, "Done. W: %d, H: %d\n", inp.width, inp.height);
}

Error log

 ![>>> File Initializing <<<
    Input File: testinp.bmp
        Reading...Error: file testinp.bmp couldn't open for read!.
    Program ended with exit code: 1][1]

image

VenushkaT
  • 1,152
  • 2
  • 19
  • 42
  • 3
    But you don't actually show the code where you try to open/read the file? – Some programmer dude Sep 18 '14 at 05:49
  • Also, you should check the spelling of the file name. Is it really `testinp.bmp` and not e.g. `testing.bmp`? – Some programmer dude Sep 18 '14 at 05:50
  • 5
    I would suggest that when you're running the application, it's not in the same working folder as your source code. – Stephen Quan Sep 18 '14 at 05:51
  • And what is the `ReadBmp` function? Is it your function? Is it a library function? Where did you get it from? – Some programmer dude Sep 18 '14 at 05:52
  • @JoachimPileborg i have checked it. thank you. it is not the issue. – VenushkaT Sep 18 '14 at 05:57
  • @StephenQuan all are located in Documenets. thank you very much. it is not the issue. – VenushkaT Sep 18 '14 at 05:58
  • @oachim Pileborg i guess Error is comming - fprintf(stderr, "Input File: %s\n\tReading...", inpfile); line, isn't it ? thank you – VenushkaT Sep 18 '14 at 06:00
  • 1
    Reduce the code to a minimal example. Also, try to create a file next to the BMP, I also guess that Stephen is right and that it will end up in a different folder instead. Use absolute paths as a workaround. – Ulrich Eckhardt Sep 18 '14 at 06:01
  • @VenushkaT in that case you have supplied insufficient information to repro the issue. The only thing I can read is `testinp.bmp` supplied is a relative reference. The question, I'm asking, relative to what? Which is why I raised an issue to the current working directory of your application. – Stephen Quan Sep 18 '14 at 06:02
  • >>> File Initializing <<< Input File: /Users/venushka/Documents/test/test/testinp.bmp Reading...Done. W: 320, H: 240 Reference File: ref5965_s.bmp Program ended with exit code: 1 – VenushkaT Sep 18 '14 at 06:03
  • "thank you. it is not the issue" - i'll take that bet. [**read this**](http://stackoverflow.com/questions/14476655/code-runs-perfect-in-g-but-not-in-xcode-cannot-find-file/14478210#14478210). – WhozCraig Sep 18 '14 at 06:03
  • @StephenQuan thank you very much i think i have got problem with initialising paths. thank you again – VenushkaT Sep 18 '14 at 06:05
  • @Ulrich Eckhardt i added files to the project in XCode or use the absolute path instead. and it works me .thank you dude. – VenushkaT Sep 18 '14 at 06:08

0 Answers0