To be honest I wouldn’t be trying to do vanilla C++ inside UE, I’d look at the UE framework and take it from there. For example:
Make a new plugin module
Use the plugin module startup as your entry point
Use UE_LOG() instead of printf()
That’s a reasonable first test to validate that you’re writing code and compiling and you’re actually inside UE as well. I’ve just been through that myself and it wasn’t overly bad.
Another option would be to make a custom blueprint, which is a bit verbose but also very easy once you get into it.
To answer your question, printf expects a variable of type const char* when it sees %s; however, you’re passing in a variable of type std::string.
This didn’t compile for me on g++ or Visual Studio so I’m not sure how you got this far, but it works fine when I use:
It’s because all “%s” does is tell printf to replace it with whatever is in the first argument after the string (because this is the first occurrence of %s. Note also your program will die if the first argument after the string is not actually a string as there are different control sequence for different types of data). In this case, the first argument after the string is hay.c_str() which contains the string “hi”
If all you wanted to do was print “hi Will” then your printf call should instead look like
printf("%s, %s
", hay.c_str(), name.c_str());
If you still have questions, I suggest you read the documentation for printf here: printf
When you get into actual Unreal C++ you’ll be pleased to find out that UE_LOG works very similarly to printf, so understanding how this works now will probably be helpful.