Hi, I have to periodically read contents of stdout which is redirected to file. please help me to resolve issue.
My problem in detail is that i have two thread in first thread , i have to execute a c file
which is continously writing output to stdout(i.e writing hello world in infinite loop) and
in second thread i have to retrieve l...
Possible Duplicate:
List of freely available programming books
Can someone recommend a free ebook for C programming for students? preferably in PDF format.
...
1) Is this unoverflowable?
long long v1, v2, result;
[..]
result = ((long double) v1 / v2) * 1000000LL;
1.a) Can I leave out the LL on the constant? And why.
2) Alternatively is this variation without a float ok?
long long l1, l2, result;
[..]
result = (1000000 * (v1 / v2) + v1 % v2);
2.a) Which has more overheads? The 1st or thi...
Sometimes with a complex header structure it happens some header is included, but it is hard to tell where from.
Is there some tool (depedency viewer?) or a method how to find the "inclusion stack" (which source / which header / which header / ...) is including one particular header file?
If the header file is included multiple times, ...
We are planning to use Splint as code analyzer for our C code base. But we never tried Splint tool before so we want your input on it's benifts, pros and cons.
...
I am trying to make a converter from postfix to infix notation and need some help. There is already a question about infix-to-postfix conversion, which gives an example I am failing to convert back. (Note: a minus sign is missing there!)
The following is the output of my converter, where the 1st "column" is postfix input, the 2nd is my ...
#include <stdio.h>
int main()
{
char TurHare;
while(1)
{
scanf("%c",TurHare);
printf("\nCharacter :%c", TurHare);
}
return 0;
}
When I compile and then run the program the output is like :
w
Character : w
Character :
where w is the input from console.
It should appear like:
w
Character : w
How t...
How much memory or other resources is used for an individual VirtualAlloc (xxxx, yyy, MEM_RESERVE, zzz)?
Is there any difference in resource consumption (e.g. kernel paged/nonpaged pool) when I allocated one large block, like this:
VirtualAlloc( xxxx, 1024*1024, MEM_RESERVE, PAGE_READWRITE )
or multiple smaller blocks, like this:
Vi...
LARGE_INTEGER lpPerformanceCount, lpFrequency;
QueryPerformanceCounter(&lpPerformanceCount);
QueryPerformanceFrequency(&lpFrequency);
(Count.QuadPart is a long long showing a CPU count)
(Freq.QuadPart is a long long showing frequency of Count for a second)
Attempting to print microseconds in real time.
stable output:
printf("%llu\...
Profiler says that 50% of total time spends inside this function. How would you optimize it?
It converts BMP color scheme to YUV. Thanks!
Update: platform is ARMV6 (writing for IPhone)
#define Y_FROM_RGB(_r_,_g_,_b_) ( ( 66 * _b_ + 129 * _g_ + 25 * _r_ + 128) >> 8) + 16
#define V_FROM_RGB(_r_,_g_,_b_) ( ( 112 * _b_ - 94 * _g_ - 18 ...
If I have some array element, how can I get individual numbers from the array element buffer[0]?
For example, suppose I have buffer[0]=0x0605040302, I'd like to first extract 2, then 0, then 6, etc.
...
I want to enable data cache. I dont have much experience with ARM as I have mostly programmed for IA32. My understanding is that I need to enable MMU to enable data cache. As I dont need the virtual memory other wise so I want to enable MMU with one-to-one mapping between physical and virtual address space for all applications.
Any help...
I know it is possible to assign an unsigned char to an unsigned short, but I would like to have more control how the bits are actually assigned to the unsigned short.
unsigned char UC_8;
unsigned short US_16;
UC_8 = 0xff;
US_16 = (unsigned char) UC_8;
The bits from UC_8 are now placed in the lower bits of US_16. I need more control o...
The socket is created and bound, then the program receives data with recv(). The question is: How do I now determine from which host + port the packet originates so that I can send data back?
Note: C and Winsock is used.
...
Hi,
Can anybody tell me the output of the below code, whether "bye" will be printed or not?
/* Thanks in advance */
#include <stdio.h>
int main()
{
system("ls -l");
printf("bye");
return 0;
}
...
We all know about -> vs . speed diff to access members in c/c++, but I am hard to find any clues of the actual cost of the simple dot operator.
I imagine its something like address-of-struct + offset, also assume the offset being the sum of all sizeof-s of all preceding members. Is this (roughly) correct?
Then compared to -> who much f...
Hi,
I am using the following code to download files from the internet:
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
int main(int argc, char** argv)
{
FILE *downloaded_file;
if ( (downloaded_file = fopen (download_path ...
Is there a free tool (some kind of a static checker) that does typedef-based type-checking for a plain C (not C++) and runs on Linux (or any kind of free Unix)? I am aware of a commercial one: PC-lint/FlexeLint. It does exactly what I want, but it's not free and Windows-only. Here is an example from it's manual:
typedef int Count;
typed...
why do we need to put a & operator in scanf() for storing values in an integer array and not while storing a string in a char array?
i.e
int a[5];
for(i=0;i<5;i++)
scanf("%d",&a[i]);
but char s[5]; scanf("%s",s); ?
we need to pass in the address of the place we store the value,since array is a pointer to first element so in the case wi...
First, hi, I'm new to stackoverflow !
Well, I was wondering if my implementation of an "itoa" function is correct. Maybe you can help me getting it a bit more "correct", I'm pretty sure I'm missing something. (Maybe there is already a library doing the conversion the way I want it to do, but... couldn't find any)
#include <stdio.h>
#in...