Unable to open include file in turbo C

So I'm trying to make a program that checks whether a number is odd or even and our prof. asked us to make a function that checks the number. She also asked us to put the .cpp file in a USB flash drive. The oddeve.cpp is the function and I can say that it's working properly, but when I transfer it to a flash drive, turbo c returns an error which says "unable to open include file 'F:\ODDEVEN.CPP'

1
2
3
4
5
6
7
#include <stdio.h>
#include <conio.h>
#include "F:\ODDEVEN.CPP"

void main(){
so on and so forth;
}
Firstly, #include of a cpp file is a big red flag. Unless you really know what you're doing and you understand what #include does, this is almost certainly a sign that something has gone very wrong. Don't do it.

Secondly, does she actually want you to build it from a USB drive? That seems odd. Perhaps she wants it on a USB drive so that you can give it to her for testing or some such.

Yeah, basically the oddeven.cpp is a function. She wants us to put the function into a flash drive. She said that she will prepare a program that will use the function that I have made.
I assume your prof intends to link that function into the program she builds, rather than #include -ing it. You should do the same.

The reason your code can't find the file, is because \ is interpreted as the escape character. The compiler thinks you're trying to escape the 'O' that follows it.

If you want to include the backslash in your string, you need to escape the backslash itself:

#include "F:\\ODDEVEN.CPP"

But, as Repeater and I have already said, don't do that. Link the function instead.
Last edited on
Nope, still doesn't work with the double backslash. I'm curious, how do you link the function?
If you're using an IDE, just include it as another source file in your project. The IDE should take care of making sure it all links.

If you're using the command-line, we can't know what commands to use without knowing what compiler you're using.
Oh I'm using turbo c++. I think turbo c cannot work with external drives
That could be it. Turbo C++ is ancient.

I'm not sure why this matters. You can work on the file on your local disk. Your prof can copy the file to her local disk and work on it. You don't need to actually use the F: drive when working - it's just a means for you to give your prof a copy.

So I've managed to make it work. It seems that you need to mount the flash drive first
Fair enough.

Regardless, though, you should still look at how to properly work with multiple .cpp files in a project, rather than abusing preprocessor includes.
turbo used to ruin code on floppies, so be aware. It has some bad behaviors on remote disks; Its been too many decades to recall exactly what not to do, but I highly recommend you do 100% of your work on the C drive, get it working, make a quick zip file backup of it, and then as the last step get it to work again on the F drive or whatever. This way if it decides to mess up the filesystem of the F drive you won't lose any work. This stuck with me because in college for 2 semesters of our first courses, a lab every week, and every single week at least 1 person would lose a disk to turbo's bug.
@jonnin Ouch! That's so bad it probably makes it into the top 100 reasons never to use Turbo... ;)
Topic archived. No new replies allowed.