+ 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

7th Apr 2019, 1:01 PM
Sayan Kundu
13 Antworten
+ 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
7th Apr 2019, 1:20 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 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.
10th Apr 2019, 3:09 PM
Sayan Kundu
+ 4
mik how do you take runtime input ?
4th Jun 2019, 4:19 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
"mik how do you take runtime input ?" Ok I got your point
4th Jun 2019, 6:51 PM
mik
mik - avatar
+ 2
~ swim ~ Thank you for your comment. This is very interesting way of thinking.
10th Apr 2019, 2:49 PM
Sayan Kundu
+ 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 !
10th Apr 2019, 7:55 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
Have you tired something like this?! https://code.sololearn.com/cHpz49x1rmH4/#
4th Jun 2019, 3:31 PM
mik
mik - avatar
4th Jun 2019, 6:20 PM
mik
mik - avatar
0
Привет
25th Apr 2019, 8:28 AM
МС ВИКУЛЯ
МС ВИКУЛЯ - avatar