Implement Timeout for one function in C
Here i have one function which is listen mode. this function listing something which i got form some device.
Here when my function is in listen mode that time i want to create timeout. if i will not get any response from particular device than i want o exit from this function and have to notify.
if during this timeout period if i will get some date from something or some action would be performed than i have to continue with work and stop this timeout.
read more
Why variables can not be declared in a switch statement just after labels?
see this code
#include<stdio.h> int main() { int i=1; switch(i) { case 1: int x=10; printf(" x is %d",x); break; } return 0; } |
Do you think this code will compile? if yes then you need to read this post….
How can i detect Windows or Linux in C,C++ programming?
Sometimes we need to write platform independent code which works in windows and linux machine without giving any flag or any modification in code or make file manually.
So in such case i usually use compiler generated macro to check the platform .
In Linux all c and c++ compiler define macro like linux, In Windows all c and c++ compiler define macro like _WIN32
so we can use this macro to separate code for linux and windows see belows example code
How can I get what my main function has returned in Linux?
In a C program if we want to give some input from terminal then we can give it by:
int main(int argc, char *argv[])
In the same way, if we want to get return value of main() function then how can we get it?
In each main() we write return 1 or return 0; how can we know what my main() has returned at terminal?
Equivalent to getch() & getche() in Linux
Once in one situation i need to use getch() and getche() function in Linux based application so i have searched a lot for Equivalent header file for conio.h in Linux,But i came to know there is not any header file/library equivalent to conio.h in linux.
I want to make a switch case base menu where the user will give his option just by pressing one key & process should be moved ahead. I don’t want to let user to press ENTER after pressing his choice.
Somebody has suggest me very magical code for getch() and getche() function for linux which is i am sharing here. read more
How post-increment & pre-increment both are evaluated in function argument?
#include<stdio.h>
int main() {
int a=5;
printf("%d %d %d",a++,a++,++a);
return 0;
}
Concept of Octal literal in C
One day while debugging one code i got one interesting things ..let me explain you by bellow’s example.
#include<stdio.h>
main()
{
int a=010;
printf("a is %d",a);
}
if you think output of this program will
“a is 10″
then your are missing something….
How to set, clear ,toggle and check a single bit in C?
As being an embedded software engineer i would really suggest you this tricks. ..! In many application you need to deal with this bit wise operation. Sometimes you know this all stuff very well but still some time it takes time to construct this logic or some time you got some mistakes in it. so i suggest you to paste this on your desk until you paste this in your mind..!
To set a bit
Use the bitwise OR operator (|) to set a bit.
number |= 1 << x;
That will set bit x.
Search in this website
our sponsors
latest comments
- tammylleanne on Implementation limitation of c programming language
- Deepak on How to access/unblock songs.pk in india?
- venkat on C programming interview questions and answers for freshers
- Ankur on How to configure mail from localhost ( wamp ) using PHP?
- ergVFyd on Huffman Encoding Using Linked List with Source Code
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language

saurabh


