There is no direct function to convert a string to upper case or lower case in Linux C. Here we collect 2 functions from internet: #include <ctype.h> static char* Str2Upper(char *str) { if(str == NULL) return NULL; char *p = str; while(*str) { *str = toupper(*str); [Read More ...]
We have a C++ project based on Linux system, so we need a good Editor but not Visual Studio since the C++ is for Linux. And, we do not want to use Ubuntu but just use Windows 7. So we decide to download Eclipse for C/C++ Windows Edition from Eclipse official site. (Note: our Windows [Read More ...]
If you are learning C, C++ or even Java, the first code example might be similar, they are all a example named Hello World. We found a interesting article which collects all Hello World example in different languages. For example: In C: #include <stdio.h> int main(void) { printf("Hello world\n"); return 0; } In C++: #include [Read More ...]
Question: In C++, is there any difference between:struct Foo { … };andtypedef struct { … } Foo; Answer: 90 down vote accepted In C++, there is no difference. It’s a holdover from C, in which it made a difference. In C, there are two different namespaces of types: a namespace of struct/union/enum tag names and [Read More ...]
This sample code is for testing some data type border value using C union. Worked on Linux OS. #include #include int main(void) { union { unsigned long int lms; unsigned short shms[2]; unsigned char bms [4]; } myms; myms.lms = 0; while (1) { printf(“long: %ld short: %d byte: %d\n”, myms.lms, myms.shms[0], myms.bms[0]); usleep(900); myms.lms++; [Read More ...]