Currently, while compiling a C program which uses pthread library function I have to specify compiler option -lpthread explicitly. Please suggest a way to configure ldconfig so that the pthread library could be used without specifying it on the command line.
presently lpthread -p gives the following output :=
[root@localhost lib]# ldco...
I got into a discussion a while back. The company I work at develop under Linux and does so in ANSI C. A lot of benefits could come from moving to C++ as far as design goes I think. Our existing code would just have to get rid of all implicit type casts since C++ is a bit stricter about that and it would compile and run as usual. But I w...
When talking about a process' memory, I heard about things like code memory and data memory.
And for the data memory, there are 2 major managing mechanisms, stack and heap.
I am now wondering how is the code memory managed? And who manages it?
Pardon me if my statement is not so clear.
Thanks.
...
I am running Eclipse CDT (Helios) for C/C++ on Windows 7 x64. At first I was having the problem of output not appearing when run in the Eclipse console until the program exited, even though it did while running in a Windows console. I discovered this had to do with buffering on the stdout stream. I was able to disable the buffering with ...
So I have a very simple program that reads the 3 first bytes of a file:
int main(void)
{
FILE *fd = NULL;
int i;
unsigned char test = 0;
fd = fopen("test.bmp", "r");
printf("position: %ld\n", ftell(fd));
for (i=0; i<3; i++) {
fread(
printf("position: %ld char:%X\n", ftell(fd), test);
}
...
i have made a program to compute roots of quauation but it does not simplify the roots.can anyone help me to simplify them
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void)
{
int a,b,c;
float d,d2;
printf(" Enter a,b and c:");
scanf("%d %d %d",&a,&b,&c);
d=b*b-4*a*c;
if(d<0)
{
prin...
Recently i had a discussion with my boss (a long time C developer) who discouraged me in using C++ streams and stick to "good old" printf & friends. Now i can understand why he is saying this and believe me i did not follow his advice.
But still this is bugging me - are there things in C that are still better in some cases than newer C+...
Possible Duplicate:
How does a compiled C++ class look like?
Hi all,
bash$cat struct.c
struct test
{
int i;
float f;
};
bash$gcc -c struct.c
The object file struct.o is of elf format. I am trying to understand what does this object file contain. The source code is just a definition of a struct. There is nothing executable...
Hi folks,
I'd like to embed Mozilla's SpiderMonkey in one of my C apps. On linux, I don't think it'll be a problem (I'm a linux user) but I must confess that I'm afraid that I have no clue on how to do it on windows using MINGW (I want the app to be portable)
Is it possible to, say, just use the dll that comes with firefox? (I, honnest...
Is there a way to print the name of the compiler and the version that was used to compile a program, something like;
printf("This is compiled with %s version %s\n", COMPILER, COMPILER_VERSION);
?
...
I know how to do X amount of leading zeros, and I know how to do X amount of decimal points. But, how do I do them both?
I am looking to have 4 leading zeros to a decimal precision of 2: 0000.00.
Therefore 43.4 would be 0043.40
...
When the texture is switched, why is the speed slow?
Code - 1
glBindTexture(GL_TEXTURE_2D,texId01);
glDrawArray(glDrawArrays(GL_TRIANGLES, 0, 4);
glBindTexture(GL_TEXTURE_2D,texId02);
glDrawArray(glDrawArrays(GL_TRIANGLES, 0, 4);
Code - 2
glBindTexture(GL_TEXTURE_2D,texId01);
glDrawArray(GL_TRIANGLES, 0, 4);
glDrawArr...
Hi.
We're working on multiple computers, executing a program coded in c/c++ and using lua api, and each one of them get crashed with different errors. It's usually either a segmentation fault, whose backtrace leads us to a call made bu liblua, or one that is usually given when trying to call a nil value as if it was a function.
The wei...
To get total installed RAM I can use popen("sysctl -n hw.memsize", "r"), but is there some library to get this info without running external tools?
...
I found GetDateFormat, but that doesn't work with null dates (where I want 00:00:0000) as output.
Is there any localized, ie. using the 'Short date:' field of 'Regional Options' from the 'Regional and Language Options' Windows configuration dialog, API I can use?
...
I'm getting an error in my switch statement with some multi-line Objective-c code:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
// Notifies users about errors associated with the interface
switc...
I need to convert ASCII to HEX and HEX to ASCII by using a C program, how can I do that?
...
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <semaphore.h>
#define WORK_SIZE 1024
pthread_mutex_t work_mutex;
char work_area[WORK_SIZE];
void *thread_start(void *);
int main() {
pthread_t a_thread;
pthread_mutex_init(&work_mutex,NULL);
pthread_create(&a_thread,NULL,thread_st...
Hello Folks!
I'm having a C programming question: I want to write a function with variable argument lists, where the specific types of each argument is not know - only its size in bytes. That means, if I want to get an int-Parameter, I (somewhere before) define: There will be a parameter with sizeof( int ), that is handled with a callba...
Hi
I need to make 4 forks 1000 times. I wrote this but it runs forever:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#define N 512
void chunk0(void);
void chunk1(void);
void chunk2(void);
void chunk3(void);
double get_time(void);
void main(void)
{
int i,j,k,iterations=0;
unsigned in...