So I'm working on an exceedingly large codebase, and recently upgraded to gcc 4.3, which now triggers this warning:
warning: deprecated conversion from string constant to ‘char*’
Obviously, the correct way to fix this is to find every declaration like
char *s = "constant string";
or function call like
void foo(char *s);
foo...
Hi, looking at the declaration for XDrawString from X11, it is
int XDrawString(Display *display, Drawable d, GC gc,
int x, int y, char *string, int length);
How come the 6th argument is type "char *" instead of "const char *"? Does drawing the string require modifying it? I've seen lots of examples where people pass in...
It seems that strtol() and strtod() effectively allow (and force) you to cast away constness in a string:
#include <stdlib.h>
#include <stdio.h>
int main() {
const char *foo = "Hello, world!";
char *bar;
strtol(foo, &bar, 10); // or strtod(foo, &bar);
printf("%d\n", foo == bar); // prints "1"! they're equal
*bar = 'X'; // seg...
Hi,
I am stuck in a printf problem. I would appreciate if I can get some help here:
In the below code, I can see the font family get displaced correctly in first printf(),
but if I set it to variable, i only get an empty string. How can I put it in a variable and have the right values? I just don't want to type 'font.family().family().s...
I am extending Python with some C++ code.
One of the functions I'm using has the following signature:
int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,
char *format, char **kwlist, ...);
(link: http://docs.python.org/release/1.5.2p2/ext/parseTupleAndKeywords.html)
The parameter of inter...
I have this a class called PPString:
PPString.h
#ifndef __CPP_PPString
#define __CPP_PPString
#include "PPObject.h"
class PPString : public PPObject {
char *stringValue[];
public:
char *pointerToCharString();
void setCharString(char *charString[]);
void setCharString(const char charString[]);
};
#endif
PPString.cpp...
In short, I would like to do this:
const char **stringPtr = &getString();
However, I understand that you can't & on rvalues. So I'm stuck with this:
const char *string = getString();
const char **stringPtr = &string;
I can live with two lines. Am I introducing problems with this hack? I should have no fear of passing stringPtr out ...
I have seen people using 2 methods to declare and define char *
Medhod-1: The header file has the below
extern const char* COUNTRY_NAME_USA = "USA";
Medhod-2:
The header file has the below declaration
extern const char* COUNTRY_NAME_USA;
The cpp file has the below defintion :
extern const char* COUNTRY_NAME_U...