C++ :: Rename Function Return -1

Jul 6, 2013

I used rename function to rename a file.

The file names are in std::string type variable.

The function usage is like this

int result = rename (old_file_name.c_str(),new_file_name.c_str());

I expected result = 0 but i get result = -1.

Does this return code is due to any file pointer holding to this file?

View 7 Replies


ADVERTISEMENT

C++ :: Remove / Rename Functions Works But Return Non-zero Number

Jan 13, 2013

My source works perfect.The problem is that the (remove(),rename()) functions works but return nonzero number, so they fails all the time.

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <fstream>

using namespace std;
int main() {
char array[100]={"1)open-write,2)open-read,3)rename,4)delete"};

[Code] ....

View 1 Replies View Related

C :: Will Return Root Statement At End Ever Return Value Other Than Value Passed To Function?

Mar 29, 2013

I'm writing some functions pertaining to binary trees. I've used recursion once before while learning quicksort but am still quite new and unfamiliar with it. And this is my first time touching a binary tree. So my question: In my addnode function, will the return root statement at the end ever return a value other than the value passed to the function?

Code:

#include <stdlib.h>
struct tnode
{
int data;
struct tnode * left;
struct tnode * right;
}

[code]....

View 4 Replies View Related

C++ :: Rename All Files In A Folder?

May 31, 2013

I want to rename all files in a folder (exactly I want to change extension file example:"FILE0001.CHK" to (FILE0001.JPG)), i know rename function , but how to use it all files, files names going sequencely (FILE0001.CHK,FILE002.CHK until FILE3000.CHK) ... How i can rename or change extension file quickly and easily.

View 1 Replies View Related

C/C++ :: Rename Not Declared In This Scope

Jan 10, 2015

For some reason my compiler says "rename not declared in this scope" .... Isn't it declared in iostream? Or is rename only for C not C++? And if it is only for C how do I rename a file in C++ then?

#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char* argv[]){
char oldname[] = "RomeTW.exe";

[Code] .....

View 2 Replies View Related

C++ :: Rename Text File In GUI CLI Project

Feb 6, 2013

How to rename a textfile in a Visual C++ CLI GUI project. I've tried using the 'rename()' function but that isn't working for me (probably because of the type of project).

View 2 Replies View Related

C++ :: Pass 2 Arrays Into Void Function And Return Values To One Function?

Feb 12, 2014

I'm trying to pass 2 arrays into a void funtion, and return values to one function.

this is the the program I'm working with, after I'm done I have to split it into 3 files, a header, a main, and a separate cpp file for the functions to live in.

#include <iostream>
using namespace std;
void processArrary(int numberCount[], int Numbers[], int intnumberSize, int numberCountSize);
int main() {
int Scores[26] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189};
int numberCount[8] = { 0 };

[code]...

The goal of this program is to separate and count the groups of numbers then output the amount of numbers in each group. Near as I can tell, everthing should work, but I'm getting all zeros to be displayed in each group.

View 6 Replies View Related

C++ :: How To Rename DataGridView Header By Double Click

Jan 24, 2012

I am having a datagrid view. In that suppose I give the header name as wrong, suppose say, instead of "test", i gave it as "tst". So i need to rename in this case. So what i expect is I need to double click that header and rename it. But in code I can't directly give it as "test", since it can be whatever. By double clicking i need to change in that display itself. I can able to catch the double click event. It is as below. Any code which makes me to edit and rename the header.

private void dgvParametersEdit_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
}

View 2 Replies View Related

C :: Main Function Does Not Return Any Values When Calling Other Function?

Jun 9, 2013

The function is supposed to return value from the file in my main, but I am getting empty value. I am trying to get better with pointer. Right now just teaching myself.

right now the only way for this code to show value is when in put the putchar(*ps) inside my readfile function. I would like to readfile to return value and print in the main function.

Code:

#include <stdio.h>
char *readfile(char filename[]);
int main(int argc, char *argv[] ) {

[Code].....

View 4 Replies View Related

Visual C++ :: Rename Files With Random Names In A Folder

May 30, 2014

I need a code for renaming multiple(bulk or all ) files in a folder.

I found one batch file script but it renaming with numbers only. But i want differntly.

[URL] .....

Example:

In a folder there are 100 images and all numbered with some digits or names.

assume that all images are belongs to "john" , so i want to rename all images with "john+ a random string".

here a random string means -> it has an array with 3000 english words, (you can predefine them by downloading from dictonary).

In the script the 3000 names are fixed, but the 1st name will be changed by my wish. that my be john, mary, sai, pavan etc...

Suggestion: you do not need to enter all 3000 words in array manually. some javscript codes are there to read input of each and evey line and them into an array.

View 2 Replies View Related

C++ :: Rename Failed With File Name Had Space / Hyphen After Unicode Support

Nov 12, 2013

I intent to use this mechanism for rename the file because the file name consists Unicode characters . I would like to know why the return value of "MoveFileExW" is false for file name consists 'space','hyphen' etc.(sometimes even without a Unicode character).for accepting 'space','hyphen' what type of conversion I would use [I.e.: Does the root cause of failure is due to CP_UTF8 type use].

Code:

//! inputPath & final_inputPath consist source and destination file name and are std::string
//! Both are in same directory F: est_files
std::wstring unicode_input_original;
int unicode_input_length_original = 0

[Code] ....

View 4 Replies View Related

C++ :: Function Will Not Return Value

Jan 14, 2015

Why my function will not return this int. It does make it into the if(... prints "test 32" but will not return the given value(123456789).

#include <iostream>
using namespace std;
int lastZero(int x[]);
int main(){
int myArray[] = {1,1,1};
lastZero(myArray);

[Code] ...

View 4 Replies View Related

C++ :: Best Way To Return Values From A Function?

Jan 24, 2014

I wanted to return a string I can do

Code:

string parseFilename(string fileName){
return fileName.subtr(/*blah*/);
}

Can I also use pointers/references here though? When would you use a pointer and when just a return statement?

View 2 Replies View Related

C :: Function Return Code / Value?

Sep 27, 2014

I have a function that needs to return a "uint8_t" value. However before doing the processing I need to perform a test on the argument to check if it's between expected boundaries. Although this function works it gives (a logical) warning that not always a value is returned although expected. What is the normal way for functions like these where I normally should return e.g. -1 in case the test doesn't succeed and otherwise the uint8_t (t) value?

Code:
uint8_t myFunc(int a) {
if (a >= 0 && a <= 100) {
// Perform actions
uint8_t = ...
return t;
}
}

View 9 Replies View Related

C++ :: How To Return A Pointer From Function

May 1, 2013

I am trying to return a pointer from a method. Below is a sample of my code.

CSubnode * CTest::GetSubNode() {
return m_psubnode;//this is declared in CTest as CSunbnode * m_psubnode
}
//in another class
m_subnode = m_ptest->GetSubNode(); //m_subnode is declared as a pointer

Is this the correct why to return a pointer?

View 2 Replies View Related

C++ :: Return Matrix In Function

Jul 4, 2013

How we can return a 3x3 matrix in c++ function.

My code is:

double *computeA() {
double *A = new double[2][2];
// some operations on A and then return
return A;
}

The error that I have in this case is:

error C2440: 'initializing' : cannot convert from 'double (*)[2]' to 'double *'

View 7 Replies View Related

C++ :: Need A Function To Return A String

Aug 13, 2014

I need a function to return a string..i need to pass input as "a,b,c,a,c,d,e" function should return out put as "a,b,c,d,e".

View 3 Replies View Related

C/C++ :: Function To Return Either Value Or Address Of That Value?

Feb 1, 2015

I'd like a function to return either a value or the address of that value by the users input. So he can call the function like:

function("adress") - gets an adress, or function("value") - gets the value

I've tried both function overloading and templates, but none of them worked. He might input a character for the address and an int for the value... but...

Another strange thing that i observed is that the value returned by the function below is 0, so the output is address 0.

class testing
{
public:
static int x;

[Code].....

View 2 Replies View Related

C++ :: Function Return Is Always True?

Oct 2, 2013

This program that I've made works fine to find midpoint, but not distance. The distancefunction always returns a 1 (true). To try to see that it wasn't the math, I added cout.setf(cout.boolalpha) to see and got a result of "true".

//This program is a start to solve basic coordinatre plane distances and midpoints
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

[Code].....

View 3 Replies View Related

C++ :: Get Return Type Of Function

Nov 21, 2012

Say I have overloaded functions with different arguments AND return types. Each set of argument has only one corresponding return type.

Code:
Vector grad(Scalar)
Tensor grad(Vector)

Later I have:

Code:
template <class T>
void test(T x) {
... Y = grad(x)
}

Then how do I automatically declare the type of Y. Do I need to make the grad function a template and specialize each of them ?

View 4 Replies View Related

C/C++ :: Is It Necessary Function Main Should Return Int?

Jan 24, 2013

If so what is the reason, and the returning int value indicates wat?

View 4 Replies View Related

C++ :: Why Return Values From A Function By Ref Address

Feb 5, 2014

You can return values from functions by ref, address or value you can also do this with parameters, so what is the difference, if you have full return of a passed parameter by ref or address why would you need to ever return the function as a whole?

For ex
Code: int nValue(int& y){
y++;
}
or int& nVlaue(int y){
return y;
}

View 1 Replies View Related

C++ :: How To Pass Function Return From Switch

Aug 23, 2013

How to do i fix this code im not good at using function, im trying to pass a statement from switch to my double passengersR i always come out with a error

this output:
Name passenger:
Enter number passenger:
Choose from A to D
if choose A
Total Regular Passenger: 6.19624e-312

did i do something wrong im not really good at function and im trying to learn how to pass switch to void function

Code:

#include<conio.h>
#include <iostream>
#include <Iomanip>
#include <string>
using namespace std;
double passengersR ()
{ double m;

[Code]...

View 4 Replies View Related

C :: Function To Return User Input

Feb 26, 2013

Firstly, I'd like to say that I'm relatively new to functions and my course standards state that I'm now supposed to relay information from the user to the program via functions, this means that I'm no longer able to use 'printf/scanf' combos in the main function.

Is it possible to do it via functions? I've tried the following method for example, but to no avail.

Code:
#include <stdio.h>
int getlowR();
int main(void)
{
getlowR();

[Code] ....

I think the following works but then lowRange is native to the function, isn't it? How can I use it outside the function? For example, how would I go about actually printing the value acquired by the function in main?

View 4 Replies View Related

C++ :: Return Parameter List Of A Function

Jan 11, 2015

Is there any function which can return parameter list of a function.

For example : get_param(f(int x,char y )) return parameter x-> int y-> char

and f_name ->f

View 3 Replies View Related

C++ :: How To Return Value Of A By Calling Function Loop

May 29, 2014

Suppose I have the following function containing while loop:

#include <iostream>
using namespace std;
int Loop () {

[Code]....

here in above code I want to return value of 'a' by calling function 'Loop'. Is there any way to do this??

for above code output should be:

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved