Society of Robots - Robot Forum
Software => Software => Topic started by: arixrobotics on October 16, 2009, 08:25:23 AM
-
Hi all,
Does any body know how to write a multiple copy of a character to an LCD using printf?
To further explain my question;
I want to write
printf("-", *3)so that the output is 3 dashes
---
Or if I write
printf("-", *14)so that the output is 14 dashes
--------------
But the arguments is wrong ie printf("-", *3) doesn't work. Does anybody know what I should put instead?
printf("-", what to write here?)
Thanks.
-
The only way to do this is to write a for loop
for(int i=0; i<3; i++) printf("-");
-
Yep, in C the for loop is how to do it.
You do need to look up the syntax for a printf statement to learn "what to write here?".
printf("-", what to write here?)
Another way is to create a string of 3 or more "-"'s and then output the string with the printf.
-
Yup i guess its for loop then. I remembered doing it somewhere else before, but maybe that was in Python. Thanks.
-
Yep, you can do that in Python.