Nov 25, 2011 at 12:25pm Nov 25, 2011 at 12:25pm UTC
hi, i'm new at C :s
is there a way to print one char for n times without using for or similar?
thanks
Nov 25, 2011 at 12:53pm Nov 25, 2011 at 12:53pm UTC
Probably, but why would you? The definition of "for" is pretty much "a loop for when you want to repeat something n times".
If it's just a challenge, you could try recursion, but that's pretty silly for this thing.
Nov 25, 2011 at 1:07pm Nov 25, 2011 at 1:07pm UTC
goto :D
1 2 3 4 5 6 7
int i = 0;
lab_start:
i++;
cout << c << endl;
if (i < 10)
goto lab_start;
But that's a really dirty way to code program logic ;o)
Last edited on Nov 25, 2011 at 1:07pm Nov 25, 2011 at 1:07pm UTC
Nov 25, 2011 at 1:20pm Nov 25, 2011 at 1:20pm UTC
That's a for loop without the actual keyword, you cheater!