C++ Current Location

What would a C++ code be for the current location of a file?
Last edited on
Prank or no prank, I'm pretty sure this is against the law in many countries.
It is? It's on a friend who bet me I couldn't. He gave me permission to try to do it, but said I probably could'nt do it.
Last edited on
In general, you cannot perform an unlawful action and just say "I was joking", or "I meant no harm", etc. An unlawful action is subject to whatever civil and penal proceedings regardless of your intention, unless expressly stated otherwise.

Want insurance? Have your friend sign a release form. Still, I cannot help you because I don't have access to such document, nor do I have any means to verifying its authenticity.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The comments above are for something else (a prank on a friend). I didn't know it would be illegal with his permission, but the I changed the topic. So that's why those comments are there. It wouldn't let me delete the post.
The __LINE__ macro will give you the current line number in a file.

1
2
3
4
5
6
7
8
9
#include <iostream>

int main(int argc, char* argv[])
{
    std::cout << __LINE__ << std::endl; // 5
    std::cout << __LINE__ << std::endl; // 6
    std::cin.get();
	return 0;
}


See http://www.cplusplus.com/doc/tutorial/preprocessor/ for more info as well as other useful stuff.
Last edited on
I don't see how that question is illegal?
i do not know how that question is illegal?
It was for something else. I friend gave me permission to mess with his computer as long as it didnt' harm it. I was going to make a program that copied itself to new folder in this path
C:\Program Files\Prank
. Then it would put itself in the registry in the startup, (simpler than copying itself to the startup folder because of different Windows Versions). As soon as he turns on his computer it starts up the Bama website (He's an Aubern Fan).
I said I needed to know to the use the shell execute command. I've never used it, but heard of it. I need to know how to get the path of the program running. And I need a C++ code to copy a file.
Topic archived. No new replies allowed.