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