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 ...]
Our R&D Manager and senior system designer Mr. Mohamed gave us the following sample for a thread sleep in Linux. #define _POSIX_C_SOURCE 199309 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <sys/time.h> #include <time.h> void mySleep() { int32_t retval struct timespec requestTm, remainTm; retval = 0 requestTm.tv_sec = 0; [Read More ...]
Dirty memory is not memory leak. Dirty memory has been released and can be re-allocate, but memory leak indicates the memory block has not released correctly so the memory can not be re-allocated. from RedHad website: Dirty means "might need writing to disk or swap." Takes more work to free. Examples might be files that [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 ...]