Posts Tagged ‘word’

There are many ways in the linux terminal to print the nth word of a given file or output. One way to do this without worrying about tabs, extra spaces or word length is to use awk. With awk, this can be done on one line by using the {print $<n>} syntax. For example, the […]

Struct sizes in C++

Posted: 24th March 2012 by Tim in C++
Tags: , , , , , , , , , , ,

Consider the following program: #include <iostream> struct A {     char a;     long b;     char c; }; struct B {     char a;     char c;     long b; }; int main() {     A a;     B b;     std::cout << “sizeof(a): ” << sizeof(a) << std::endl;     std::cout << “sizeof(b): ” << sizeof(b) << std::endl;     return 0; } To summarize, it […]