c

Why is -o a candidate for deletion from the Microsoft compiler and linker?

I came across the following and I am wondering what implications it is going to have on my cygwin/gnu environment should I be using something other than -o to name the output from a compile? Has there been some new standard adopted and do other compilers adhere to it? What would be the motivation for removing -o? DOS PROMPT>type c...

What is an example in which knowing C will make me write better code in any other language?

In the Stack Overflow podcasts, Joel Spolsky constantly harps on Jeff Atwood about Jeff not knowing how to write code in C. His statement is that "knowing C helps you write better code." He also always uses some sort of story involving string manipulation and how knowing C would allow you to write more efficient string routines in a diff...

How to interpret this debugging error

As a hacker-in-training, I decided to go about making my own string_reverse function that takes a string, allocates memory for a new string, and returns a pointer to a new string, but I'm not getting what I desire, as this returns a segmentation fault. #include <stdio.h> #include <stdlib.h> char* string_reverse(char* string); char* s...

Calculating size of an array

Hi, I am using the following macro for calculating size of an array: #define G_N_ELEMENTS(arr) ((sizeof(arr))/(sizeof(arr[0]))) However I see a discrepancy in the value computed by it when I evaluate the size of an array in a function(incorrect value computed) as opposed to where the function is called(correct value computed). Code...

Best approach for safeguarding char[] when getting back from function?

I am maintaining a piece of C code where char arrays are frequently populated by passing them into functions and using the result as a string that is written to output. However there is no checking done on the array after it has been processed by the function and I'm wondering what the best approach to take is? One approach is to set th...

(Windows) Monitoring API calls in C

Is there anyway to monitor API calls on your system in C? ...

Searching files in C on Windows

How would one search for files on a computer? Maybe looking for certain extensions. I need to iterate through all the files and examine file names. Say I wanted to find all files with an .code extension. ...

how to remove a node from an xml file using a C program ?

Hello Guys, I am using libxml/xmlparser.h library in my program to parse the xml file. Is there any function in that library that can remove a node from the xml file? I want to completely remove the node, i.e. its attributes and properties also. ...

Which editor to use? for coding c/c++.

Hi!, From past 9 years i have been using vi as my editor and have found few things which i haven't seen simple and non-stupid solutions, could any of you have better solutions. when-ever i open a fresh file to code.. getting by default the header description.. with date,time and author name etc...basic things in place. When-ever i ope...

In case of integer overflows what is the result of (unsigned int) * (int) ? unsigned or int?

In case of integer overflows what is the result of (unsigned int) * (int) ? unsigned or int? I was auditing the following function, and suddenly I came out with that question. In the below function, it is vulnerable at line 17. 1. // Create a character array and initialize it with init[] 2. // repeatedly. The size of this character ...

What is a good multiplatform vector graphics library for C/C++?

I'm looking for a good multiplatform library for vector graphics in C/C++. Any recommendation or thougts? Thanks EDIT: Thanks for all your answers!! Could anyone tell me the pros and cons of qt vs cairo, for example? Cairo got more votes, but it seems to be from 5 to 7 times slower according to some benchmarks... ...

Best way to handle memory allocation in C?

I think I've got a good grasp on how to handle memory in C++ but doing it in C is different I'm a bit off. In C++ I've got constructors and destructors, I've got the pretty straightforward new and delete and I know how to encapsulate it using RAII, using with smart pointers and within classes. However in C I can't handle malloc and fre...

How would I write this program for controlling a remote control car with voltage drops?

So my partner and I need some help; we are working on a final project which is for an electrical engineering degree. Our problem, no one really knows much programming in the class. We need help or some general ideas on how to program this. The project: We have a monster truck with two IR (infra red) sensors detecting it's path via volt...

Which web-development language is best for a C programmer?

Question I program in C (ANSI C89/ISO C90) in a *n*x environment on a regular basis. I am now in a position where it would be beneficial for me to learn a web-development language. In particular, I'm looking to learn a language which: ...exploits my background as a C programmer. ...can produce the level of interactiveness of a web-sit...

Unions in C

The idea behind this question is to understand the deeper concepts of using union and using it in different way so as to save memory.. My question to all is-- lets say there is structure struct strt { float f; char c; int a; } and the same structure represented in union union unin { float f; char c; int a; } Now...

Converting Endianess on a bit field structure

Hi I need to convert a bit-field structure from little-endian to big-endia architecture. What is the best way to do that, as there will be issues in byte boundaries, if I simply swap the structure elements. Ex Structure is: struct { unsigned int b1:1; unsigned int b2:8; unsigned int b3:7; unsigned int b4:8;...

Examples of Union in C

I'm looking for some union examples, not to understand how union works, hopefully I do, but to see which kind of hack people do with union. So feel free to share your union hack (with some explanation of course :) ) ...

How to detect 'strict aliasing' at compile time?

'Strict aliasing' optimization needs special care from the source code, s.a. using a union instead of pointer casts. Is there a way to detect using preprocessor directives (#if/else) whether the compiler is trying to do such optimizations? I would like to maintain the old and non-strict-aliasing-prepared code path for processors and com...

Regular Expressions in C

I'm curious, does anybody know a good way to do regular expression matching in C? The only way I can think of is through Flex. Is this the only way or is there a better way? Thanks! ...

Xerces/Xalan: UNC path as argument for document function?

I'm transforming an XML document by using Xerces-C 2.5 and Xalan-C 1.8. The XSL contains a "document" function, that references a file on the network. Unfortunately I cannot access this file by HTTP. I've only got the UNC path. Xerces refuses to parse the referenced document, because WinSockNetAccessor::makeNew is called in Xerces as th...