+ 3
How to format string to show accurate decimal places using Macros and Preprocessors in C ?
I have tried the string manipulation approach and it works fine. But is it possible to use macro function to do so? Check my code:- https://code.sololearn.com/cV4SLXVHEabV/?ref=app
13 Réponses
+ 4
As you want a user defined accuracy, it can't be done with macros. At most, you can rewrite your function as a macro
+ 4
~ swim ~ Its possible with the right resources of file handeling and directory handeling functions, which would only increse the level of complexity than the first approach of simple string manipulation function, though my goal was to be simpler than that.
+ 4
mik how do you take runtime input ?
+ 3
"mik how do you take runtime input ?"
Ok I got your point
+ 2
~ swim ~ Thank you for your comment. This is very interesting way of thinking.
+ 2
~ swim ~ I have done something nearly like that with makefile to take the wanted input and compile the code with its correctly defined macro, and done another one that generates a header file with a static array of random generated numbers written directly in the code, then use it to compile another file using the result
It is indeed overkill ... but so much fun !
+ 1
Have you tired something like this?!
https://code.sololearn.com/cHpz49x1rmH4/#
+ 1
How about now?
https://code.sololearn.com/cHpz49x1rmH4/#c
0
Привет