How to convert an ASCII char to its ASCII int value?

I would like to convert a char to its ASCII int value. I could fill an array with all possible values and compare to that, but it doesn’t seems right to me. I would like something like The point is atoi() won’t work here as it is for readable numbers only. It won’t do anything … Read more

Ping with timestamp on Windows CLI

note: code to be used inside a batch file. To use from command line replace %%a with %a Start the ping, force a correct line buffered output (find /v), and start a cmd process with delayed expansion enabled that will do an infinite loop reading the piped data that will be echoed to console prefixed … Read more

Comparing the values of char arrays in C++

Assuming student::name is a char array or a pointer to char, the following expression compares pointers to char, after decaying sName from char[28] to char*. Given that you want to compare the strings container in these arrays, a simple option is to read the names into std::string and use bool operator==: This will work for … Read more

How can I check if a string is a valid number?

2nd October 2020: note that many bare-bones approaches are fraught with subtle bugs (eg. whitespace, implicit partial parsing, radix, coercion of arrays etc.) that many of the answers here fail to take into account. The following implementation might work for you, but note that it does not cater for number separators other than the decimal … Read more