3
votes
1answer
125 views

How to fix legacy code that uses <string.h> unsafely?

We've got a bunch of legacy code, written in straight C (some of which is K&R!), which for many, many years has been compiled using Visual C 6.0 (circa 1998) on an XP machine. We realize this is ...
1
vote
2answers
73 views

Is there a stricter strtoull() in any ubiquitous C library?

I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number. strtoull() does set ...
-1
votes
2answers
145 views

Assigning strings to pointer in C Language

I am a new learner of C language, my question is about pointers. As far i learned and searched pointers can only store addresses of other variables, but cannot store the actual values(like integers or ...
0
votes
3answers
156 views

How can I handle this string concatenation in C in a reusable way

I've been writing a small C application that operates on files, and I've found that I have been copy+pasting this code around my functions: char fullpath[PATH_MAX]; fullpath[0] = '\0'; ...
0
votes
3answers
93 views

How to manage intermediate outputs efficiently?

I am implementing a C preprocessor in C... I have the three functions: trigraph replacing function Line splicing function comment removing function However these functions work separately on ...
5
votes
4answers
43k views

Initializing char array with string

I don't remember how I got to the thread, but I was reading its replies and one of them states that you should never initialize a char[] with a string literal. My question: Is initializing a ...
-2
votes
1answer
239 views

C Minishell Command Expansion Printing Gibberish

I'm writing a unix minishell in C, and am at the point where I'm adding command expansion. What I mean by this is that I can nest commands in other commands, for example: $> echo hello $(echo ...
6
votes
4answers
591 views

Should functions of a C library always expect a string's length?

I'm currently working on a library written in C. Many functions of this library expect a string as char* or const char* in their arguments. I started out with those functions always expecting the ...
2
votes
3answers
847 views

Why do people put '\n' at the beginning of strings?

Very often I get into C code where printf format strings start with \n: printf( "\nHello" ); This in my opinion is an annoying thing that offers no advantages (rather many disadvantages!) with ...