c

How do I get the upper and lower limits to the global data area in C?

I am making a garbage collector to develop an appreciation for how they work. I can process registers as well as heap and stack memory to find potential references to allocated blocks. But processing the global data memory has eluded me. Is there a way to get the upper and lower bounds of the global memory space in C (I'm using GCC on...

strtok giving Segmentation Fault

Hi, Why does the below code give Seg. Fault at last line? char* m=ReadName(); printf("\nRead String %s\n",m); // Writes OK char* token; token=strtok(m,'-'); As said, read string prints w/o problem, but why cannot split to tokens? ...

PHP error: libphp5.so: undefined symbol: _estrndup

I compile Apache-MySQL-PHP by hand to build a custom install using the configure options from below. When I start apache it fails to start and adds the below error in the error_log. * Apache 2 * Mysql 5.0 * PHP 5.1 * CentOS Linux 5.4 * GCC compiler the error in apache log httpd: Syntax error on line 54 of /opt/clamp/etc/httpd.conf: Can...

Add one header from a different project to my project using automake

I'm working on a relatively big project that is using automake build system. Now the problem is that I need to link the project with a library from another project (this works fine), but I also need to include a header from the other project source tree (api.h). INCLUDES = -I@REMOTE_PROJECT_DIR@ in Makefile.am doesn't work, because th...

clarity on permissions in windows.

Hi, I work on linux. I donot have much idea in windows. How the permissions of files are organized in windows? Do we have any api like chmod in unix to change the permissions? ...

create custom LAMP distribution like XAMPP

I wish to make a self contained LAMP distro software package from source with at least the following: * php must have mysqli, ldap and GD support * all required .so's must be included (like libpng needed by GD) (self contained) I managed to make one but i keep patching quirks to it, SO i thought to start from a wide-used one like XAM...

Getting Variable dynamic in c.

I have one requirement in C. char abc[]="hello"; char hello[]="world"; Using abc whether we can get the hello variable's value in C. I know it is possible in some of the languages like Perl, Php, Bash,., Is it possible in C? ...

Using strdup into malloc reserved space

I've never used malloc to store more than values but I have to use strdup to order the lines of an input file and I dont get a way to make it work. I though using strdup() to get a pointer to each line and later, put each one into a space according to the number of lines reserved with malloc(). I dont know if I have to do it like reser...

What does this assembly code mean?

Recently, i am looking into some assembly codes generated by GCC. But I dont understand some of them: movl $0x2d, 0x4(%esp) In the second operand, what does 0x4 stands for? offset address? And what the use of register EAX? ...

c++: getting ascii value of a wide char

Hi all! let's say i have a char array like "äa". is there a way to get the ascii value (e.g 228) of the first char, which is a multibyte? even if i cast my array to a wchar_t * array, i'm not able to get the ascii value of "ä", because its 2 bytes long. is there a way to do this, im trying for 2 days now :( i'm using gcc. thanks! ...

Difference between float and double

I know, i've read about the difference between double precision and single precision etc. But they should give the same results on most cases right ? I was solving a problem on a programming contest and there were calculations with floating point numbers that were not really big so i decided to use float instead of double, and i checked...

Why can't I use killall with the new name given to a child process with execvp() on Linux?

Hi, Assume I have an executable called 'exe' which spawns a child process. This child process needs to become a daemon and we need to change its name. Next I want to use killall to send a signal to this process using the new name, but I need to use the old name. The order of events is as follows: start 'exec' fork -> exit if parent d...

C linux cursor position

Hi I want to print current time (by using printf) in same place, but i want to do it in infinite loop eg: while(1) {printf("Date and Time are %s", asctime(localtime(&current))); } . So before i use printf i should move cursor backward to its staring position. How to do it ? thx in advance ...

C boolean logic

I have been trying some programs in the C Language and come across to this... #include<stdio.h> int main() { int j=3,k; k=!5&&j; printf("%d",k); return 0; } can anyone figure out what is the problem in this if i compile the program i will result to 0 and when i tried the same code in c# public void logic() { ...

Compiler fails to catch variable redefinition in conditional block

int bar = 2; if (bar) { int bar; } Neither gcc or Clang manages to issue a warning (or error) for this, and the program crashes immediately on launch. Is there a good reason for this? It doesn't seem like it would be something hard to catch. It's the basics of block scoping: the nested scope inherits the names of the enclosing block...

libgtk version problem on ubuntu

I installed gtk+2.0 version 2.18.3 but when i run command dpkg -i libgtk2.0-dev_2.18.3-1_i386.deb i have the next error but when i checked the /usr/lib/libgtk2.0-0 i found the version of the libgtk is 2.12.9 why the new installtion not override the pre one? and what i should do now? ----------------------------------------ERROR----...

Report duplicates in array of structures using qsort?

What I'm trying to accomplish: I am making 3000 requests and capturing 8 bytes of that request. I stick the response in: struct negs { int neg_num; char neg_key[9]; }; where neg_num == i (the request number) and memcpy(nego[neg_count].neg_key, recv_data+73,8); I need to find any duplicate neg_keys in the nego struct. I am...

Pointer issue in C - what am I doing wrong here?

For a bit of background, I'm writing a meter reading application in C for a small 16-bit handheld computer that runs a proprietary version of DOS. I have a screen that displays meter information and prompts the user to type in a reading. When the user presses the enter key on the unit, the following code will execute: /* ... * beginn...

run c programmes from cmd / dos in xp

Hi , this maybe a noobish question so sorry, is it possible to run c programmes from cmd? I am in the process of creating a programme that takes 3 command line arguments, a string seperator and 2 file names and i have conditions such as if more or less command line items are passed then print an error etc i cannot test this from dev-c...

To malloc or not to malloc, that is the question!

Do I need to malloc when creating a file to write to? The file will be based on the contents of 2 others, so would I need to malloc space for the writeable file of sizeof( file a ) + sizeof( file b) + 1? Sorry if this makes no sense; if it doesn't then I guess I need to go read some more :D Essentially, I have 2 txt files and a stri...