Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Salvatore Terress14-Nov-23 6:41
Salvatore Terress14-Nov-23 6:41 
AnswerRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
jschell14-Nov-23 7:46
jschell14-Nov-23 7:46 
GeneralRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Salvatore Terress14-Nov-23 11:52
Salvatore Terress14-Nov-23 11:52 
GeneralRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
jschell15-Nov-23 3:22
jschell15-Nov-23 3:22 
GeneralRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Salvatore Terress15-Nov-23 7:05
Salvatore Terress15-Nov-23 7:05 
QuestionHow do you pass an int by reference to a function? Pin
Calin Negru11-Nov-23 3:57
Calin Negru11-Nov-23 3:57 
AnswerRe: How do you pass an int by reference to a function? Pin
Greg Utas11-Nov-23 4:19
professionalGreg Utas11-Nov-23 4:19 
GeneralRe: How do you pass an int by reference to a function? Pin
Richard MacCutchan11-Nov-23 4:49
mveRichard MacCutchan11-Nov-23 4:49 
GeneralRe: How do you pass an int by reference to a function? Pin
Greg Utas11-Nov-23 5:40
professionalGreg Utas11-Nov-23 5:40 
GeneralRe: How do you pass an int by reference to a function? Pin
Richard MacCutchan11-Nov-23 6:09
mveRichard MacCutchan11-Nov-23 6:09 
GeneralRe: How do you pass an int by reference to a function? Pin
honey the codewitch15-Nov-23 4:38
mvahoney the codewitch15-Nov-23 4:38 
GeneralRe: How do you pass an int by reference to a function? Pin
Greg Utas15-Nov-23 5:15
professionalGreg Utas15-Nov-23 5:15 
GeneralRe: How do you pass an int by reference to a function? Pin
Calin Negru11-Nov-23 5:31
Calin Negru11-Nov-23 5:31 
QuestionStruct initalization valid ? Pin
Maximilien7-Nov-23 8:08
Maximilien7-Nov-23 8:08 
AnswerRe: Struct initalization valid ? Pin
Mircea Neacsu7-Nov-23 8:17
Mircea Neacsu7-Nov-23 8:17 
GeneralRe: Struct initalization valid ? Pin
Maximilien7-Nov-23 8:39
Maximilien7-Nov-23 8:39 
AnswerRe: Struct initalization valid ? Pin
markkuk7-Nov-23 11:48
markkuk7-Nov-23 11:48 
GeneralRe: Struct initalization valid ? Pin
Maximilien8-Nov-23 2:32
Maximilien8-Nov-23 2:32 
GeneralRe: Struct initalization valid ? Pin
CPallini8-Nov-23 2:37
mveCPallini8-Nov-23 2:37 
AnswerRe: Struct initalization valid ? Pin
jschell8-Nov-23 6:01
jschell8-Nov-23 6:01 
AnswerRe: Struct initalization valid ? Pin
honey the codewitch8-Nov-23 10:03
mvahoney the codewitch8-Nov-23 10:03 
GeneralRe: Struct initalization valid ? Pin
k50548-Nov-23 12:31
mvek50548-Nov-23 12:31 
For C code, using {0} is safe, as far as I know, and initializes all bytes of the struct to zero. For C++, I don't know. It looks like maybe all bytes are initialized to zero, as per C, but then constructors are called with an empty argument list. If the first struct member has a constructor, then the compiler will look for a constructor that takes a single int. If no such constructor exists, compilation fails.

Both g++ and clang++ warn about struct members with missing initial values when -Wextra is used.

For C, though, it can be useful, since you can also use named initializers e.g.
C
struct S {
  int i;
  double d;
  char str[10];
};

struct S s { .d = 123.4; }; 
will assign 123.4 to s.d, and all other members will be set to zero. You can use named initializers in C++ too, but you still get warnings about struct members with missing initializers.
Keep Calm and Carry On

GeneralRe: Struct initalization valid ? Pin
honey the codewitch8-Nov-23 21:31
mvahoney the codewitch8-Nov-23 21:31 
GeneralRe: Struct initalization valid ? Pin
k50549-Nov-23 4:12
mvek50549-Nov-23 4:12 
GeneralRe: Struct initalization valid ? Pin
honey the codewitch9-Nov-23 4:51
mvahoney the codewitch9-Nov-23 4:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.