Im wondering how to make this simple program look a bit more organized, say by listing 10 ASCII chars per line rather than just going on and on like it currently is. Here is the code for it, compile it and you'll see what i mean.
Im wondering how to make this simple program look a bit more organized, say by listing 10 ASCII chars per line rather than just going on and on like it currently is. Here is the code for it, compile it and you'll see what i mean.
did you forget something??
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Hehe forgot the code...
#include "stdafx.h"
#include <iostream.h>
int main()
{
for(int x=0; x<256; x++)
{
cout<<x<<". "<<(char)x<<" ";
}
return 0;
}
See if this works:
#include "stdafx.h"
#include <iostream.h>
int main()
{
int y = 0;
for(int x=0; x<256; x++)
{
if(y > 9)
{
y = 0;
cout<<"\n";
}
cout<<x<<". "<<(char)x<<" ";
y++;
}
return 0;
}
"If you tell the truth, you don't have to remember anything"
-Mark Twain
easier than that. Use modulus operator.
Code:#include "stdafx.h" #include <iostream.h> int main() { for(int x=0; x<256; x++) { cout<<x<<". "<<(char)x<<" "; if (x%10==0) cout<<endl; } return 0; }
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
it works now.
>easier than that. Use modulus operator.
...pot heads, such slackers....why make it so easy all the time? You could do something like this
>#include "stdafx.h"
>#include <iostream.h>
>int main()
>{
double i;
>for(int x=0; x<256; x++)
>{
>cout<<x<<". "<<(char)x<<" ";
i = double(x)/10.0;
for(int j=1; j<256/10+1; j++) if(i == j) {cout << endl; break;}
>}
>return 0;
>}
better yet, replace the extremely efficient for loop stated above by yours truly, with if(i == 1 || i == 2 || i == 3 || i == 4|| i == 5 || i == 6 || i == 7 || i == 8 || i == 9 || i == 10 || i == 11 || i == 12 || i == 13 || i == 14 || i == 15 || i == 16 || i == 17 || i == 18 || i == 19 || i == 20 || i == 21 i == 22 || i == 23 || i == 24 || i == 25) cout << endl;
now that is clean code, and none of that slacker bs to be found