c

Methods/Tools for solving a Mystery Segfault while running on condor

I'm writing a C application which is run across a compute cluster (using condor). I've tried many methods to reveal the offending code but to no avail. Clues: On Average when I run the code on 15 machines for 2 days, I get two or three segfaults (signal 11). When I run the code locally I do not get a segfault. I ran it for nearly 3 we...

C - Pointer problems - how to fill array with value pointer is pointing to?

I have a function void add_car(char *car) { park.buffer[park.size] = car; park.size ++; } car is a string like "XYZ". Atm, It seems to assign the carpark buffer array element to an address. Thus if I fill the array with 10 cars, I get back 10 cars, but each of them is the latest one, since the address of car was overwritten. H...

Location of static pointed memory

I read that pointers passed by malloc() & calloc() get allocated memory dynamically from the heap. char *Name="Ann"; In this case, is the static string {'A','n','n','\0'} also stored in the heap? Can I modify the string using the pointer? ...

Use callgrind as a sampling profiler?

I've been searching for a Linux sampling profiler, and callgrind has come the closest to showing useful results. However the overhead is estimated at 20--100x slower than normal. Additionally, I'm only interested in time spent per function (with particular emphasis on blocking calls such as read() and write(), which no other profiler wil...

Whats the difference between the two command lines? (SegFault)

I have written a code that maps to a shared memory location,so that the first program opens a shared memory block and stores some data in it.And the second program reads the shared data. Whats the difference between the two command lines: 1. if(argc<2) { printf("USAGE:%s text-to-share\n",argv[0]); } This code gives me a Segm...

How to hide window from "Applications" tab in task manager?

Hi guys, I have question regarding the CreateWindowEx function. I have 2 windows, a main one and a popup one. I want a popup window to hide everywhere. It is currently not displayed in taskbar and it is not even visible in alt+tab menu. However it is visible on "Applications" tab in task manager. What flags do I need to use in CreateWin...

Efficient search for shortest and longest strings from an array of long strings in C

Given an array of pointers to ordinary C NUL-terminated (and typically very long) strings, how can we best find the smallest and the largest strings? ...

C Program: square brackets when printing 2D character array

Hello, I am having a confusing issue -- for me at least, this may be very simple and I am missing something. I am trying to initialize a 2D array of variable size, The array is a part of a struct. I am having no issue allocating memory for the array but when I try to assign characters to the array, or print them I receive unexpected resu...

Tiny snippet for converting 4 hex characters to an integer in C

I need to parse strings of four hex characters to an integer. The characters appear inside a longer string, and there are no separators - I just know the offset they can be found in. The hex characters are case insensitive. Example with offset 3: "foo10a4bar" -> 4260 I'm looking for a snippet that is Short (too much code always crea...

How to download web content using C?

I have to write a C parser for online blogs and different word manipulation features. I know how to parse / tokenise stings in C, but how would you on execution download the pages content to a local /tmp directory as an HTML file so I can save the information (the blogs) into a string using I/O? Or, just grab the block of text directly...

Single quotes vs. double quotes in C

When to use Single quote and double quote in C programming ? ...

looking for GSM SMS component/ActiveX

Hi, I'm looking for a delphi component or ActiveX which can access to GSM devices through serial port. I need to send and receive binary data sms (8-bit coding). ...

What's a very efficient way to have a bulk mailer app keep accurate track of its progress?

We have a console application (currently .NET) that sends out mail in bulk to people that have subscribed to a mailing list. We are re-implementing this application because of limitations that it currently has. One of the features it must have, is that it can resume after an unexpected interrupt of its operation. This means that every t...

Combobox style edit control in winAPI

Hi again, In my winAPI project done in C++ (no MFC, no .net...), I am creating comboboxes in place of edit controls, because of the nice blue border. In many windows forms and dialogues, edit controls also have this look. There are two problems: This doesn't seem like like "proper" way to make an edit control look that way. What if I ...

Why does this program cause a segfault?

hi guys i am new so i am sure you will help i have some trouble with skip list here is code #include <stdio.h> #include<stdlib.h> #include<time.h> #include <string.h> #define P 0.5 #define MAX_LEVEL 6 struct sn{ int value; struct sn **forward; }; typedef struct sn skipnode; typedef struct{ skipnode *...

Understanding Realloc

Realloc is used to reallocate the memory dynamically Suppose I have allocated 7 bytes using the malloc function and now I want to extend it to 30 bytes. What will happen in the background if there is no sequential (continously in a single row) space of 30 bytes in the memory? Is there any error or will memory be allocated in parts??? ...

gcc - writing and executing code in the bss - setting the permission flags

Hi all, I am generating x86-64 code at runtime in a C program on a linux system (centos 5.4 to be exact). I generate my bytecodes into a global array as shown below char program[1024 * 1024] __attribute__((aligned (16))); and then call into it via a function pointer. My issue is, when I compile the program like this gcc -std=gnu99...

What is the difference between STATIC and EXTERN in C?

Possible Duplicate: static vs extern C What is the difference between static and extern in C? ...

Problem with combobox

Whenever I resize my controls in my window, in resopnse to a WM_SIZE message, they resize and redraw themselves fine. But my combobox control (a dropdown list) disappears whenever I give it a resize message, until I hover over it to bring it back. There are two possibilities, either it is not redrawing when I resize it, or it is being h...

Calling manually loaded code (AT&T + C) (g++)

I'm implementing a program which loads pure code from a file and calls the first instruction. No matter what I do, I get a Segmentation fault when my call instruction is executed. What do I do wrong? char code[65536]; ... __asm__("movl code, %eax"); __asm__("call *%eax"); ...