I am relatively new to c++ and I am trying to make a program that converts time specs in the form of n1y n2n n3d n4h n5m n6s to seconds. One of the functions that I am trying to create is a function to check for if the time spec given is a valid time spec. To be valid the time spec must be in the format above (only the whitespace between the different elements can vary). For this I am trying to utilize strpbrk and search for "yndhms" in the time spec provided to the function as a string (const char*). I am trying to test my logic with the code given below. The issue that I am having is that the code does not actually output anything at the end of its runtime (either input_form is null, or I am not utilizing printf correctly). I am also having an issue trying to figure out how I would check for cases such as "abcd32y 10n 20d 10h 10m 20s" because according to my current logic that would be a valid time spec which it is not.
Since you say you're writing a C++ program why are you using C-strings instead of std::string? Why the C-stdio functions instead of C++ streams? What header files are you #including?
Where are you allocating memory for that pointer (input_form)?
You also may want to look closely at lines 2 to 5 in the above code. You may want to look up what exactly that first word on each of those lines means.