291 points · by brudgers · 11y ago · 112 comments
school_t uiuc = {
.school = "University of Illinois at Urbana-Champaign",
.location = "Urbana, IL",
.program = "BS Computer Science",
.started = 1251158400,
.left = 1336608000,
.accomplishments = {
"Minor in International Studies in Engineering, Japan",
"Focused on systems software courses",
NULL
}
};[0] https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html [1] https://nickdesaulniers.github.io/blog/2013/07/25/designated...
https://github.com/torvalds/linux/blob/master/drivers/video/...
good read, both the post and the socket99 code.
[gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)]
0) Have brought a pen or cell phone.
1) Always get their business card or contact info.
2) When you get someone's business card, always write down where you met them and what you want to ask or show them. Otherwise, you end up with a pile of cards and no memory of who they were from.
2.1) If you actually had them type their email into your phone, sketch out the email, but don't send it.
3) follow up within 3 days or you'll forget.
--- a/resume.c
+++ b/resume.c
@@ -118,7 +118,7 @@ void print_job(job_t * job) {
}
}
-int main(int argc, char * argv) {
+int main(int argc, char ** argv) {
int i = 0;
while (jobs[i]) {
@@ -127,4 +127,4 @@ int main(int argc, char * argv) {
}
return 0;
-}
\ No newline at end of file
+}There is no string in c so you use char pointers instead. But in previous code he used char, which is usually defines a single string, but main actually inputs an array of string so it should have been char* (pointer to pointer of char, or pointer to 'string')
Basically he did something like this in Java
public static void main(String args)
instead of
public static void main(String args[])
char * argv
is a pointer to a string (or a single character). char ** argv
is a pointer to an array of pointers to strings. The latter is used since it allows for multiple arguments in (the number being `int argc`).This picture shows the second example in terms of pointers:
* The struct members and variables pointing at string literals should be const.
* People do break this all the time but typedefs ending in _t are reserved by POSIX.
* Your C99 style struct initializers are valid but it's notable that one popular compiler, MSVC, will not like them.
* If we are being idiomatic I would suggest pointer arithmetic to iterate instead of using a counter i.
This resume is not web scale enough. We need to wrap the resume in node.js so it can be non-blocking for big data. It should be written in an esoteric JS variant and transpiled to ES5 because everyone knows ES5 is unreadable. Oh and the storage of his education and job history should really be stored in a NoSQL database like MongoDB that way he can shard asynchronously. When he presents the resume in his interviews it should be wrapped in a webkit container.
* Avoid using NULL in your resume. It has a negative connotation, and makes your resume look bad.
* Make use of as many existing libraries as possible, to show that you're not the kind of programmer that wants to invent the wheel on every occasion.
* Try to obfuscate your resume a little (but not too much!) As it is written here, your reader can easily guess what the program will do, and he/she will not even want to run it anymore.
* #include a portfolio of your work inside your resume.
The code compiled fine with MSVC 2013 (simply 'cl resume.c'). No warnings at all.
Well, the CVE guys need to keep their job.
On another topic, I have noticed you post this sort of trollish c bashing on almost every hn thread about c. It's fine that you prefer something else, but maybe time to give it a rest?
If C didn't need this kind of attention to safety, Clang, GCC and others wouldn't have all those nice analyzers built-in, not MISRA would be required.
Besides, looking for my post history and fellow comments, I am not alone in this.
How exactly is one more idiomatic than the other?
Prefer array notation to the use of pointers. C programs in particular impose very few restrictions on the use of pointers; aliased pointers may lead to unexpected dependencies. Without help, the compiler often cannot tell whether it is safe to vectorize code containing pointers.
Source: https://software.intel.com/sites/default/files/8c/a9/Compile... (Section 5.1)
const char **a;
for (a = job->accomplishments; *a; a++)
printf(" - %s\n", *a);
And job_t *j;
for (j = jobs; *j; j++)
print_job(j);
The person who wrote this code seems to dislike `for`s for some reason it seems, these are pretty obvious places to use one IMO, using an index `i` or not. Doing it with a `while` separates out the initialization, condition, and increment in his code, and 'continue' won't work like you normally want it too.hahaha, shame on me, I always use _t to abbreviate types or make custom ones, ex. uint_t, fraction_t, bitfield32_t, etc...
bitfield32_t: https://gist.github.com/AldoMX/526e84da13b00ac0c75e
I've seen companies shutting down/relocated because of bad recruiters filtering good programmers like this.
You don't have to go this far. My CV is a HTML page, and I just refuse to convert it to Word. It hinders the recruiters who just like to buzzword search their database.
Could an editor put the slanty thing over the e in the title?
initialize
while (test) {
...
increment
}
instead of for (initialize; test; increment) {
...
}OCharles originally did it in Perl/Moose and with a module of mine (Acme::URL) which is how I stumbled across the CV in the first place - https://web.archive.org/web/20120119150530/http://ocharles.o...
I still have a copy of it online at: http://old.bertjwregeer.com
There's an argument that using a 'for' construct groups together the details of the loop (initialization, the loop condition, iteration update), which can aid readability.
(You don't have to search the loop body to find how things change between iterations)
Of course, nothing forces a for() loop to have iteration behavior entirely dependent on only what's in the 'for'. In my experience this seems to be discouraged, however, preferring to use 'for' only when there is a predictable and simple iteration pattern.
In the end, it's just a matter of preference and style. :)
They're not differently purposed, the union is just used to define more contextual labels for equivalent fields, and thus make initialisation more readable within each domain.
The point is that they're not three completely separate data structures, they're a single data structure with context-dependent field labelling.
Pasting in code from the internet and running it is a little scary though. I wonder of we can spot the backdoor here. :P
This makes my head hurt!
I'd prefer thing_t *thing.
But it's a nice concept
imo, the star should be with the variable name. because, in this case, a reader could think that both thing_ptr and thing are pointer to a thing_t
"thing_t thing_ptr, thing, other_thing_ptr" is imo more readable
thing_t* ptr1;
thing_t* ptr2;
not thing_t* ptr1, ptr2 /* <= oops */;