Related
Rajman Why is the first line valid and the rest not. I though the first is a shorthand for the second. const char *c = "abc"; // Why valid?
const char *b = { 'a' , 'b', 'c', '\0' }; // invalid
const int *a = { 1, 2, 3, 0 }; // invalid
Shafik Yaghmour In the
Yuval I want to create a buffer structin C99 that wraps a null-terminated string along with the actual string length: typedef unsigned int uint_t;
typedef unsigned char uchar_t;
typedef struct {
uchar_t * buffer;
uint_t length; // excluding null-termi
Yuval I want to create a buffer structin C99 that wraps a null-terminated string along with the actual string length: typedef unsigned int uint_t;
typedef unsigned char uchar_t;
typedef struct {
uchar_t * buffer;
uint_t length; // excluding null-termi
username #define LENGTH 6
typedef char data_t[LENGTH];
struct foo {
const data_t data;
...
}
...
void bar(data_t data) {
printf("%.6s\n", data);
struct foo myfoo = {*data};
printf("%.6s\n", foo.data);
}
I'm trying to use this structure to
username #define LENGTH 6
typedef char data_t[LENGTH];
struct foo {
const data_t data;
...
}
...
void bar(data_t data) {
printf("%.6s\n", data);
struct foo myfoo = {*data};
printf("%.6s\n", foo.data);
}
I'm trying to use this structure to
username #define LENGTH 6
typedef char data_t[LENGTH];
struct foo {
const data_t data;
...
}
...
void bar(data_t data) {
printf("%.6s\n", data);
struct foo myfoo = {*data};
printf("%.6s\n", foo.data);
}
I'm trying to use this structure to
username #define LENGTH 6
typedef char data_t[LENGTH];
struct foo {
const data_t data;
...
}
...
void bar(data_t data) {
printf("%.6s\n", data);
struct foo myfoo = {*data};
printf("%.6s\n", foo.data);
}
I'm trying to use this structure to
username #define LENGTH 6
typedef char data_t[LENGTH];
struct foo {
const data_t data;
...
}
...
void bar(data_t data) {
printf("%.6s\n", data);
struct foo myfoo = {*data};
printf("%.6s\n", foo.data);
}
I'm trying to use this structure to
k33n I get the following code: const char *newLine = "\n";
printf('Content: %c\n', *newLine);
What is happening now is a memory error. Why is this so? Acorn The code crashes with a memory error (segmentation fault) because printfa null-terminated string is ex
k33n I get the following code: const char *newLine = "\n";
printf('Content: %c\n', *newLine);
What is happening now is a memory error. Why is this so? Acorn The code crashes with a memory error (segmentation fault) because printfa null-terminated string is ex
Wengers I have the following code: #include <iostream>
int main(){
int v1 = 20;
int *p1 = &v1;
int **p2 = &p1;
return 0;
}
What I'm trying to do here is point one pointer to another and it works fine in this case. I make p1 point to a cons
floating ice I have been trying to solve this problem for several hours. This didn't work, although I found some similar questions. I have a union in a struct. Now, I want to initialize const variables of this structure. struct length
{
int minutes;
int
Wentz I'm looking for a way to declare and initialize a constant struct in a class header file. As you can see, the class is being used by the MFC application. The layers on my MFC dialogs never change, so I want to constantly modify them. I am looking for som
floating ice I have been trying to solve this problem for several hours. This didn't work, although I found some similar questions. I have a union in a struct. Now, I want to initialize const variables of this structure. struct length
{
int minutes;
int
Justin Thurman I'm trying to solve an encoding problem that needs to return a result with a given struct. The structure is defined as: struct Answer
{
const char* const* lastNames;
unsigned numberOfPeople;
}
where lastNames is a pointer to last names
Spatny, Cuba I'm currently trying to implement a tree structure in C++. I start with the following code: class Tree {
Node * const first;
Node * last;
public:
Tree(Node * const root)
{
first = root;
las
Spatny, Cuba I'm currently trying to implement a tree structure in C++. I start with the following code: class Tree {
Node * const first;
Node * last;
public:
Tree(Node * const root)
{
first = root;
las
Allombe I have the following class: class A {
A(B* b, unsigned int size_in);
private:
unsigned int size;
// Pointer whose address and pointed-to data shouldn't be changed
const char* const p1;
// Pointer which should hold a copy of p1's
Allombe I have the following class: class A {
A(B* b, unsigned int size_in);
private:
unsigned int size;
// Pointer whose address and pointed-to data shouldn't be changed
const char* const p1;
// Pointer which should hold a copy of p1's
Allombe I have the following class: class A {
A(B* b, unsigned int size_in);
private:
unsigned int size;
// Pointer whose address and pointed-to data shouldn't be changed
const char* const p1;
// Pointer which should hold a copy of p1's
Za'tar How can I make Alt.1 work as expected by passing an array pointer and getting the requested reference to the array in Alt.1? struct mystruct
{
int id1;
int id2;
};
const struct mystruct local_struct[] = {
{0, 55},
{1, 66},
};
// Alt.1
Becky I'm trying to figure out how to convert a const struct reference to a non-const struct pointer. I have a struct called Foo: struct Foo
{
Foo& someFunc()
{
//do something
return *this;
}
};
I have a method: struct Bar
{
F
Becky I'm trying to figure out how to convert a const struct reference to a non-const struct pointer. I have a struct called Foo: struct Foo
{
Foo& someFunc()
{
//do something
return *this;
}
};
I have a method: struct Bar
{
F
Tara Sala: I have an external function decal in C: //extern void goCallback(const struct libvlc_event_t*, void*);
Defined in go: //export goCallback
func goCallback(event unsafe.Pointer, userData unsafe.Pointer) {
log.Fatal("TODO goCallback")
}
When comp
Tara Sala: I have an external function decal in C: //extern void goCallback(const struct libvlc_event_t*, void*);
Defined in go: //export goCallback
func goCallback(event unsafe.Pointer, userData unsafe.Pointer) {
log.Fatal("TODO goCallback")
}
When comp
Tara Sala: I have an external function decal in C: //extern void goCallback(const struct libvlc_event_t*, void*);
Defined in go: //export goCallback
func goCallback(event unsafe.Pointer, userData unsafe.Pointer) {
log.Fatal("TODO goCallback")
}
When comp
Peter Smith In C, structures are usually passed by pointers to prevent copying data to too many objects. I don't know, does this really matter? Doesn't the compiler prevent unnecessary copying? For example, if I mark a variable const, will the compiler optimiz
Tara Sala: I have an external function decal in C: //extern void goCallback(const struct libvlc_event_t*, void*);
Defined in go: //export goCallback
func goCallback(event unsafe.Pointer, userData unsafe.Pointer) {
log.Fatal("TODO goCallback")
}
When comp
Tara Sala: I have an external function decal in C: //extern void goCallback(const struct libvlc_event_t*, void*);
Defined in go: //export goCallback
func goCallback(event unsafe.Pointer, userData unsafe.Pointer) {
log.Fatal("TODO goCallback")
}
When comp