C++ :: Function To Return String - File Size

Feb 24, 2012

Where i can get ready function, which return string, which describe size of file?

For example
4 = 4 b
1045 = 1,01 Kb
and etc.

View 3 Replies


ADVERTISEMENT

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++ :: Creating 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 2 Replies View Related

C :: Return A String To Then Call It On Main Function?

May 26, 2013

I'm trying to return a string to then call it on main function.

Code:
const char* coiso(int chave){
char str [50];
sprintf(str,"%d",chave);
char txt[50] = ".txt";
strcat(str,txt);
return str;
}
int main () {
const char* info = coiso(8);
printf("%s",info);
}

If I do a printf("%s",str) in coiso function it works but the following code doesn't work.

View 10 Replies View Related

C++ :: Use Recursion Function That Return If String Has Same Letters

Aug 12, 2013

I've to use recursion function that return if the string has a same letters:

for example: - fff = true
- fFf = false

I did this but the return answer is always: NOT!

bool iSameLetters(char str[SIZE]) {
if(str[0]='')
return true;
else {
if((str[0] && iSameLetters(str+1) == str[0]))
return iSameLetters(str+1);
return false;
}
}

View 3 Replies View Related

C/C++ :: Why To Use Return Type For String Function As Char

Oct 6, 2012

If we are using strcpy() for copying the string. As we are passing pointers to it It will copy the string & no need to return the string .This function will finely work with return type as void then why Ritchie has used it as char* strcpy()?

View 4 Replies View Related

C :: Compute Permutations Of Any String Entered - Function Will Not Return A Value

Jun 11, 2013

This is my program, for now it is intended to compute permutations of any string entered, but the function ox will not return the final x value. ox is the function that actually computes the permutations so the return of the x value is critical.

Code:
#include<stdio.h>
#include<string.h>
int ox(int x);
int main() {
int x;
char input[10];

[Code] .....

View 2 Replies View Related

C :: Return File Contents As String?

Oct 1, 2014

I am trying to code a function which will read a file on system and return its content back as string. Code is below.

Code:
char * readtxt(){
FILE * fptr;
char c;
static char txt[30];

[Code]....

I suppose txt variable is pointer. But I need to return the file content as string so the function structure should look like

Code:
returnType function(){
return "File Contents as String";
}

View 13 Replies View Related

C/C++ :: Return File Contents As String

Oct 1, 2014

I am trying to code a function which will read a file on system and return its content back as string. Code is below.

char * readtxt(){
    FILE * fptr;
    char  c;
    static char txt[30];
    int len=0;  
    fptr = fopen("C:UsersTestDesktopDev est.txt", "r");  

[Code] ....

I suppose txt variable is pointer. But I need to return the file content as string so the function structure should look like

returnType function(){
return "File Contents as String";
}

How can I achieve this ?

View 2 Replies View Related

Visual C++ :: Check For File Existence - Function Will Fail Or Return Non-zero Value

Sep 21, 2013

Just wonder is it possible that if the file exist, this function below will fail by returning non-zero value?

_access( INIFilename, 00 )
00 - check for Existence only

I noticed that sometimes if even the file exist, the function will fail or return non-zero value. So trying to find out and duplicate this error. It tends to happen intermittently. How can I find out what causing this error?

Code:
char INIFilename[256]="C: emp est.ini";
unsigned long Error = 0;
if( _access( INIFilename, 00 ) != 0 ) {
Error= GetLastError();
printf ("Failed to access INI file %s (%ul)", INIFilename, Error);
}

View 5 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++ :: Reads Process And Return Values From It - Application Crashes Because Of Buffer Size

Nov 11, 2014

I have an application that reads a process and return values from it. The problem it works fine with small processes but i have some processes that are about 1GB or even 2GB and when i try to read such big processes the application crashes. I'm trying to find a way to read the process memory in chunks of maximum 10 MB. The read code looks like:

Code:
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, entry.th32ProcessID);
unsigned char *p = NULL;
MEMORY_BASIC_INFORMATION info;
for (p = NULL; VirtualQueryEx(hProcess, p, &info, sizeof(info)) == sizeof(info); p += info.RegionSize)

[Code] ....

This reads the info.regionsize which can be as large as 100 MB. Is there any way to read it in chunks ?

View 12 Replies View Related

C++ :: Open File And Read In Rows To String Vector And Return Vector

Jun 7, 2012

I have a cpp app that reads in a number of files and writes revised output. The app doesn't seem to be able to open a file with a ' in the file name, such as,

N,N'-dimethylethylenediamine.mol

This is the function that opens the file :

Code:
// opens mol file, reads in rows to string vector and returns vector
vector<string> get_mol_file(string& filePath) {
vector<string> mol_file;
string new_mol_line;
// create an input stream and open the mol file
ifstream read_mol_input;
read_mol_input.open( filePath.c_str() );

[Code] ....

The path to the file is passed as a cpp string and the c version is used to open the file. Do I need to handle this as a special case? It is possible that there could be " as well, parenthesis, etc.

View 9 Replies View Related

Visual C++ :: Retrieving Size Of Each String In Order To Produce A New Buffer For Concatenated String

Feb 25, 2013

What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?

String s("Hello");
String t("There");
1. s = s + t;
2. s += t;

View 3 Replies View Related

C++ :: Convert And Return C Format String To String?

Jun 8, 2014

heres the function:

string ToString ( const char * format, ... )
{
char buffer[256];

[Code]....

these function do the same of the sprintf() function. but instead we use a variable for add the result, i want to return the result. when i use it:

string f;
f=ToString("hello world");
gives me several errors:
"error: crosses initialization of 'std::string f'"
"error: jump to case label [-fpermissive]"

View 7 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 :: 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

C :: How To Return As A Pointer To A String

Aug 1, 2014

How to return as a pointer to a string?

View 5 Replies View Related

C :: Masking A Bit String Of Unknown Size

Mar 2, 2015

I have an assignment where I am trying to get the frac bits of a IEEE number representation. The number of exp and frac bits are given as parameters from the main, but I am unsure what bit mask to use as a one-size-fits mask.

View 5 Replies View Related

C++ :: Adding String But It Return Some Integer Value

Jun 10, 2013

string str = "sfsdfsd"

and i want to add like str[3]+str[4]

but it return some integer value

View 3 Replies View Related

Visual C++ :: Return String Length

Jun 7, 2013

PHP Code:

int processString(xxx)
{
   //do something
   return non-null terminated string length


To make the function work better we change its internals

PHP Code:

int processString(xxx)
{
   //do something
   return null terminated string length


This phenomenon can be observed by use of mutibyte to wide char conversions, string copy , concatenation functions of MS etc ....

Should I minus one in the return value of the second function to match both versions ?

View 6 Replies View Related

Visual C++ :: Return String From COM Method

Nov 28, 2013

I try to make dll and install it under "Component Services". I tried to make method that return string but when i test it i don't get any result :

Code:
STDMETHODIMP CSimpleChat::CellMe(BSTR name, BSTR** helloMessage) {
CString temp = _T("Hi ");
temp += name;
temp += ", welcome to the simple chat server!";
BSTR str = temp.AllocSysString();
*helloMessage = &str;
return S_OK;
}

View 8 Replies View Related

C/C++ :: String Getting Printed Even After Size Of Array Is Exceeded?

Mar 4, 2015

#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
char name[5];
cout<<"Enter your name";
cin>>name;
cout<<"Your name is"<<name;
getch();
}

In the above program the size of the array of the variable name is 5. which means the variable cant store more than 5 characters.

which also means

If I give the string "LINISH"
It should only print LINIS

But while the program is running, Even if I type a 10 characters string, It is getting printed Completely..why?

#include<iostream.h>
#include<conio.h>
void main(){
clrscr();
char name[5];

[Code] .....

In this program when I input a string for the variable name,It is getting printed completely, irrespective how many characters are there in the string.But If the string (which is input to the second variable that is game )holds more than 5 characters. the input of the first variable(name) is getting disturbed..why?

look at the below cited output to be more clear about my doubts.

OUTPUT NO:1

Enter your name:LINISHFRANCIS (Note that the input holds more than five chars)
Enter your game:GOLF(input is less than five chars)

LINISHFRANCIS loves GOLF(Two inputs are getting printed comopletely)

OUTPUT NO:

Enter your name:LINISHFRANCIS (Note that the input holds more than five chars)
Enter your game:FOOTBALL(input is more than five chars)

ALL loves FOOTBALL [Note that "ALL" is the last three letters of FOOTBALL

I am using TurboC++ for windows 7

View 5 Replies View Related

C++ :: Vector String Return Length Error

Jul 10, 2013

The error is unclear but suggests Its received a bad pointer from another heap. It references dbgheap.c line 1322 and assertion failure

I have two string vector functions the first is called from the main function, the second is called from the first.

Their purpose is to receive a string of text and numbers in a semi-specific format, which the main body of the code reads from a text file, and delaminates the data as to return the first variable in the string as the variable name and the second as the variable value. Along the way it filters out a lot of the unwanted whitespace and punctuation.

E.g "{ VariableNameA 123 }" would be returned as "VariableNameA" And "123"

The code works perfectly for most of the lines in the text file but fails on one particular line where the first variable is 25 characters long. Basically it works for anything 22 characters or less. There are never more than 4 elements in the vector and each element is never intended to be longer than 25 characters.

It fails trying to return from the second split function to the first split function.

Is there a limit to the size of each vector element? I'm struggling to find a way round this without having to rewrite the whole thing.

vector<string> split(const string &s, char delim) {
vector<string> elems;
split(s, delim, elems);
return elems;

[Code] ....

View 4 Replies View Related

C Sharp :: How Selected Value In Combobox Return String

May 29, 2013

string st=combobox1.selectedvale.tostring();

combo box return 2 item ,

1:text
2:value

The value of combo not type of(int),the value type (string)

How value ofcombobox return data with type(string)?

View 2 Replies View Related

C/C++ :: Read From File / Assign As String And Call Function As Argument

Oct 29, 2014

I try to use passing function as argument but I'm stuck. I have two questions: First, I try to call uppercase and open .txt in tfm Second, How can I read characters from in.txt as string and assign to char content[] ?

#include <stdio.h>
void tfm( char str_filename[], void(*pf_convertion)( char content[]));
void uppercase(char content[]); //converts all letters to uppercase
int main(){
puts("-------------------------------");
printf("tfm:
");
tfm("in.txt", uppercase);

[Code] ....

View 2 Replies View Related







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