473,473 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Rename using windows command for a c++ project

1 New Member
Hi I'm currently trying to use the windows command ren / rename in a c++ project. However, when I try to rename a file it's says that the file does not exist, but it does.

Expand|Select|Wrap|Line Numbers
  1. comando = "ren %s %s";
  2. const char *p = comando.c_str();
  3. system(p);
  4. p = NULL;
  5. delete p;
Any thoughts about this???
Dec 9 '12 #1
2 2365
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code.

Also, I've moved your question to the C/C++ forum.
Dec 9 '12 #2
Banfa
9,065 Recognized Expert Moderator Expert
If the file exists you probably have the directory wrong.

Why are you calling system. I generally consider calling system to be a mistake in all cases, Windows has an API function to do this MoveFile (link to Windows help)
Dec 10 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: adamsbarker | last post by:
i'm using Windows to access an ssh server. everything works perfect until i try executing files (ssh2_exec) and sending/receiving files (ssh2_scp_send/ssh2_scp_recv)... in the function manual at...
3
by: farshad | last post by:
Hello, Could someone tell me which way can we use windows command(for example Create New Folder) in visual c++ programing or use dos command without using dos prompt. best regards farshad
7
by: John F | last post by:
Not exactly a C question (sorry), but I couldn't find a ng that seems more suitable... On the Unix shell command line I can successfully write cc -DPATH=\"abcd/\" program.c -o program to...
3
by: garyusenet | last post by:
Dear Professionals, I have recently been using the wonderful krypton toolkit and am trying to use them in my small hobby application. I include this bit of info as an aside really because i'm...
0
by: ptek | last post by:
Hi, I'm using Vstudio 2005 and I did a Windows Application project where I also want to read arguments from command line and output some text when appropriate (for example, typing the correct...
1
by: yadin | last post by:
hi! i need to know how i can run ussal commands that i ussally type at the windows command prompt from a python file. that is for example from the windows command prompt i ussually type "cd...
0
by: =?Utf-8?B?Um9zaGFuIFIuRA==?= | last post by:
Hi All, I need to reboot the system at the beginning of installation, how can I do this, I am using Windows Installer 3.1 version. I am developing a msi which will install applications, drivers...
4
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, I continue with installation. I create three windows services. Each service has a Installer class.
0
by: Andreas Tawn | last post by:
Does anyone know how to properly kick off a script using Windows Import os and add os.system("pause") at the end of AutomatedTestRun.py to keep cmd open. As far as not seeing any output, I...
2
by: powerfulperl | last post by:
I want to locate a string 'Local=IN' from a file and I am sure that this string is located within 100 lines(assumption) from the beginning of the file out of 5000 lines. The 100th line start with the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.