01-14-2012, 03:44 AM
I'm using the header file standard for C++ stdio.h, specifically for the rename function, however one problem to me that I see is that it expects input parameters for const char strings.
The big problem here is the const part that i'm trying to deal with to coincide with what it wants as my inputs. If it wasn't for that everything would be fine...
Here's what i've got so far (Ignore the Usage.h and Usage function, it's not the problem here and that works fine, it's more the loop right around where i'm trying to rename to the new value)
This line here:
Arr won't convert to a proper "const char *" input, I get a weird value when trying to parse that out. I have tried seeing if I can cast a string from the std namespace over to that specifier, but no avail. It asks for a const value and therefore doesn't want to accept psuedo-const values calculated upon runtime (which is what my loop does), it wants a definite value that it can take in before calculating it to ensure that it stays it's const value and it's a valid value before startup.
Maybe it's just because it's now 3:45AM in Mountain timezone lol... I'll see tomorrow possibly what's going on.
The big problem here is the const part that i'm trying to deal with to coincide with what it wants as my inputs. If it wasn't for that everything would be fine...
Here's what i've got so far (Ignore the Usage.h and Usage function, it's not the problem here and that works fine, it's more the loop right around where i'm trying to rename to the new value)
Code:
#include "stdafx.h"
#include "stdio.h"
#include "Usage.h"
#include <string>
#include <iostream>
int main(int argc, char *arg[])
{
system("color 0F");
if(argc < 2)
Usage();
else
std::cout << "Beginning Process - Please Wait...\n\n";
const char* inputf;
short unsigned int inputl = 0;
for (__int64 x = 1; x < argc; x++)
{
inputf = arg[x];
inputl = strlen(inputf);
char Arr[500];
for (short unsigned int i = 0; i < inputl; i++)
{
if (i == 0 || Arr[i-1] == '\\' || Arr[i-1] == ' ') {
Arr[i] = char(toupper( inputf[i]) );
} else {
Arr[i] = char(tolower( inputf[i] ));
}
}
short unsigned int ren_task = 0;
ren_task = rename(inputf, Arr);
if ( ren_task == 0 )
std::cout << "File successfully renamed:\n\t--" << arg[x] << "\n\n";
else
std::cout << "Error renaming file: \n\t--" << arg[x] << "\n\n";
}
return 0;
std::cin.get();
}
This line here:
Code:
ren_task = rename(inputf, Arr);
Arr won't convert to a proper "const char *" input, I get a weird value when trying to parse that out. I have tried seeing if I can cast a string from the std namespace over to that specifier, but no avail. It asks for a const value and therefore doesn't want to accept psuedo-const values calculated upon runtime (which is what my loop does), it wants a definite value that it can take in before calculating it to ensure that it stays it's const value and it's a valid value before startup.
Maybe it's just because it's now 3:45AM in Mountain timezone lol... I'll see tomorrow possibly what's going on.