User Tools

Site Tools


programming:c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
programming:c [2019/07/30 15:44]
admin
programming:c [2020/04/03 12:02] (current)
admin
Line 1: Line 1:
 +===== Size of stuff at compile time =====
 +<code c>
 +// Size of array of structs
 +struct TargetsCombination InvalidSequences[] = { InvalidSocketDimmSquence, InvalidSocketDimmSquence2 };
 +int foo = sizeof(InvalidSequences)/sizeof(InvalidSequences[0]);
 +
 +// Variable sized string array
 +char* names4[]={"John", "Paul", "George", "Ringo"}; // Four elements
 +LEN = (sizeof(names4)/sizeof(names4[0]));
 +
 +// However if above string array is inside of a struct, then need to define array length as some max length possible, then go until strings == NULL
 +typedef
 +struct TargetsCombination
 +{
 +  char *pTargets[MAX_ELEMENTS];
 +  unsigned int NumTargets;
 +  char *pErrString;
 +} TARGETS_COMBINATION;
 +
 +while(pTarget != NULL) {
 +
 +</code>
 +
 ===== Find the bugs ===== ===== Find the bugs =====
 Not that I found them right away, but this is an example of **real** code with real bugs. Not that I found them right away, but this is an example of **real** code with real bugs.
programming/c.txt · Last modified: 2020/04/03 12:02 by admin