Convert null argument to " " (C++)
I am having a massively frustrating time attempting something simple: I have a C++ script, and would like the last argument passed in to be optional. If it is specified, assign it a variable, else have that variable point to "" (or " ", don't care which).
Here's pseudocode of what I'd like to do: Code:
#include <string.h> |
"" is a char const*
How about Code:
#include <cstdio> // to declare printf |
That works. I guess my problem was I wasn't declaring mychar as a char const*. Grrr, get me back to python...
|
It looks like while I was answering, you were editing the original question into an entirely different question.
Quote:
Since br was out of scope, even printing the initial blank would not be reliable. It depends on arbitrary choices that can be made by the compiler. |
Quote:
Consider the following: Code:
#include <iostream> |
Just to fix the worst parts:
Code:
#include <string.h> |
All times are GMT -5. The time now is 09:32 AM. |