c

Making specific word in string uppercase C

Hey all, I'm trying very hard to figure out a way to parse a string and "highlight" the search term in the result by making it uppercase. I've tried using strstr and moving a pointer along and "toupper"ing the characters, to no avail. char * highlight( char *str, char *searchstr ) { char *pnt=str; int i; pnt=strstr(str,searchstr...

How to comment a few lines, with comments inside

Hello.. I have a program like this int main(){ char c; int i; /* counter */ double d; return 0; } if I want to comment out char, int and double, and just have return uncommented, can I do it? the comment that's already there stops the comment.. Is there an easy/fast way to comment that out? ...

Conditional linking of sections in a program using linker command file input to a linker?

hi, Is it possible to link conditionally(like an if..else) by using the linker command file? Suppose i am having two two conditions and i need to link two different section by checking that condition in the linker command file while linking? I am using a custom linker (star core - a flavor of gcc) of Freescale. __Kanu ...

Why are malloc() and printf() said as non-reentrant ?

In UNIX systems we know malloc() is a non-reentrant function (system call). Why is that? Similarly, printf() also is said to be non-reentrant; why? I know the definition of re-entrancy, but I wanted to know why it applies to these functions. What prevents them being guaranteed reentrant? ...

How do I separately convert a struct timeval into two 32 bit variables?

A struct timeval is 64 bit long. I need, for a project, to convert this long (struct timeval) into two 32 bit chunks, and put each chunk into a different variable. How do I do this? Thanx in advance. ...

How to get HTML tables using xpath in c?

I'm using libxml2 in my c project. I was wondering how could I grab all tables in a html file using xpath. Sample code will do the trick. I need to parse the data in html table. Thanks EDIT: This is a row of the table: <tr class="report-data-row-even"> <td class="NormalTxt report-data-cell report-data-column-even"><nobr>0.0285</nob...

What is guaranteed about the size of a function pointer?

In C, I need to know the size of a struct, which has function pointers in it. Can I be guaranteed that on all platforms and architectures: the size of a void* is the same size as a function pointer? the size of the function pointer does not differ due to its return type? the size of the function pointer does not differ due to its param...

How can I pass a string to a C function from Objective-C and get a value back?

I have an Objective-C view controller class, from which I am trying to call a straight-C (not Objective-C) function. I want to pass in a string variable by reference, set its value inside the C function, and then back in my view controller I want to convert this to a normal NSString object. Since I can't pass in an NSString object dire...

How to genrate a monochrome bit mask for a 32bit bitmap

Under Win32, it is a common technique to generate a monochrome bitmask from a bitmap for transparency use by doing the following: SetBkColor(hdcSource, clrTransparency); VERIFY(BitBlt(hdcMask, 0, 0, bm.bmWidth, bm.bmHeight, hdcSource, 0, 0, SRCCOPY)); This assumes that hdcSource is a memory DC holding the source image, and hdcMask is ...

Where to put include statements, header or source?

Should I put the includes in the header file or the source file? If the header file contains the include statements, then if I include that header file in my source, then will my source file have all of the included files that were in my header? Or should I just include them in my source file only? ...

Can I link MSVCRT statically with mingw?

I have C program I compile with mingw on Windows. It works fine but requires MSVCRT.DLL. I want to link that statically (like I can do in Visual Studio). Is this possible? I tried -static flag to gcc and it didn't make any change. What about C++ program using also standard C++ library? ...

How do I access members of this structure in C?

I'm working with this structure in C: /** This structure describes an Internet host address. */ typedef struct pj_hostent { char *h_name; /**< The official name of the host. */ char **h_aliases; /**< Aliases list. */ int h_addrtype; /**< Host address type. */ int h_length; /**< Length of...

What determines maximum local datagram size? (PF_UNIX / SOCK_DGRAM)

Can local message-based sockets transfer messages up to the SO_SNDBUF/SO_RCVBUF limits, or where can the so-called 'fixed maximum length' be determined for a descriptor created with socket(PF_UNIX, SOCK_SEQPACKET, 0) or socket(PF_UNIX, SOCK_DGRAM, 0)? ...

warning: left-hand operand of comma expression has no effect

i see this warning How to do fix it? Temp += (Table[i, temp3] - (MSB[i] ^ 0x1)); warning: left-hand operand of comma expression has no effect ...

variable declaration problem inside struct

I declared a Normal Structure In C: typedef struct arr_struct{ int* original; int size; int first[size/2]; int second[size-(size/2)]; }; when compile it gives me: test.c:11: error: ‘size’ undeclared here (not in a function) any explanation? ...

C Language Data Structure Visualisation

Are there any C-language static analysers out there that create graphical diagrams of the data structures in a body of C code? I'm thinking along the lines of the data displays in the DDD (Data Display Debugger) but that work from static analysis of the source code. Any diagram notation welcome (UML etc.) and it can run on any platform...

Rearranging array elements

Not sure if it is a duplicate. Given a data structure having first N integers and next N chars. A = i1 i2 i3 ... iN c1 c2 c3 ... cN. I need an in-place algorithm to rearrange the elements as A = i1 c1 i2 c2 ... iN cN. ...

Segmentation Fault for directory modifications?

Here is my code: /* * main.c * * Created on: 15 Oct 2010 * Author: mohit */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/dir.h> #include <sys/unistd.h> void print_usage(); int main(int argc, char *argv[]) { int i; char *directory; char *name; //Iterate through command line argum...

how to build a autorun program in linux

i want to create a program that should run as auto . when i insert a pendrive it shall execute at the terminal plz can somebody help me to program in C ...

Detecting signed overflow in C/C++

At first glance, this question may seem like a duplicate of http://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c, however it is actually significantly different. I've found that while detecting an unsigned integer overflow is pretty trivial, detecting a signed overflow in C/C++ is actually more difficult ...