Can any one explain how the statement '2' in the following statements is a legal one.
int & ref = 3; // Illegal statement - Compiler error.
const int& ref=3 ; // Compile and executes properly.
Thanks in Advance,
Arun (1 Reply)
hello everybody!
I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(){
int fileDescriptor;
fileDescriptor =... (2 Replies)
Hello,
I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it:
char* getext(char *file)
{
char *extension;
int i, j;... (5 Replies)
hello everybody!
i have aproblem! i dont know how to concatenate const char* with char
const char *buffer;
char *b;
sprintf(b,"result.txt");
strcat(buffer,b);
thanx in advance (4 Replies)
Is it possible to have a non-const reference variable as an OPTIONAL/DEFAULT parameter to c++ function
ex
void read(string &data,int &type=0 /*or something*/) ;
so i will call
read(data);
//or
int type;
read(data,type);
printf("Type =%d",type);
I found one dirty workaround
... (2 Replies)
Hi all,
I have some questions about functions.
In a code I have (a .hpp file) there is this line which says:
const Class_1_Name* Class_2_Name::MethodName(int ipart) const {return (ClassName*)_ref_to_method.At(ipart);}
My questions are:
What is the meaning of the two constants,... (2 Replies)
Hi
In the following code, why the variable 'i' still retains the value 10 instead of 11? Why it is not possible to alter this variable's value?
int main() {
const int i = 10;
*(const_cast<int*>(&i)) = 11;
cout << i << endl; // Ans: 10
} (6 Replies)
Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially):
xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’:
xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’
The same error with all c++ constructors - gcc 4.4.4.
If anyone can throw any light on... (8 Replies)
Dear all,
I am using C and ROOT for programming. And I need to incorporate following in my code.
char *fps=NULL;
int dec=0,sign=0;
float mean = h1->GetMean(1); //0.001298
fps= fcvt(mean,6 , &dec, &sign);
I need to provide this mean as const char to some other function to get... (8 Replies)