Hello, I would like to pose a very simple question, does anyone know how to clear the command window of text, and give it a name(Eg. Cosmos's Program)
I would like to make room for different lines of text in my program, and also give it a name, for obvious reasons.

Thanks guys!

To clear the screen: click
To set your title:

#include <windows.h>
int main()
{
    SetConsoleTitleA("This is my Consolewindow!");
    return 0;
}

Thank you! It worked...
I have another question, it's about renaming a file from a certain location on the computer, I know copy is:

char cp[500];

    if (strstr(argv[0],"Foldername")==NULL)
    {

sprintf(cp, "copy \"%s\" \"path"", argv[0]);
system(cp);

*Don't know how to add code tags, sorry*


How would I program this to suit the file "path" in this case?


Thanks

Thank you! It worked... [.....]*Don't know how to add code tags, sorry*

No problem.

Code Tags (please click and read)

How would I program this to suit the file "path" in this case?

I don't understand what you mean, could you give an example?

Sure, this is the program that is copying the file to the startup folder so it boots up every time, so that I can prompt the user of info:

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <stdio.h>


using namespace std;

int main(int argc, char *argv[])
{
    char cp[500];

    if (strstr(argv[0],"Startup")==NULL)
    {
       sprintf(cp, "copy \"%s\" \"C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\\"", argv[0]);
       system(cp);
        
    }
 return EXIT_SUCCESS;
}

I would like to rename the file, from this location, so I don't get mixed up with the two originals.

Meh, not sure if the code thing worked...
EDIT, nope, it didn't...

Thanks...

You could use the dos "move" command to do this?
Also argv[0] is your own programs name, did you realise this?

You could use the dos "move" command to do this?
Also argv[0] is your own programs name, did you realise this?

Niek

How would I use the dos move command to rename the file? What syntax should I use?
I know that's my programs name, I just can't get the syntax right, I've tried several methods...

If you want to use C and Doscommands.
Say you have a file called blah.txt. To rename it you type in DOS move blah.txt new.txt and the file is now named new.txt.

But personally I would use rename(). The less "system" commands, the better!

Try implementing this in your code.

Yeah, I tried this, whats wrong with my syntax?
My file is called testing123(orig)

rename("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\testing123.exe");

I know this only tells it the location of the first file, I can't seem to add on my new file extension name...

Thanks

Yeah, I tried this, whats wrong with my syntax?
My file is called testing123(orig)

rename("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\testing123.exe");

You didn't tell rename() what the new name would be.

rename("C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\testing123.exe", "C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\backup.exe");

Now the file is renamed to backup.exe

Thank you very much, it worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.