//I want to know to print out two array colums. For example,
char list_ch[][2]={'1','a',
'2','b',
'3', 'c',
'4', 'd',
'5', 'e',
'6', 'f'};
//I want to print them out in two colums
//please tell me the easiest way, I am just beginning to C.
//I want to know to print out two array colums. For example,
char list_ch[][2]={'1','a',
'2','b',
'3', 'c',
'4', 'd',
'5', 'e',
'6', 'f'};
//I want to print them out in two colums
//please tell me the easiest way, I am just beginning to C.
int i;
for(i=0;i<6;i++)
printf("%c\t\t%c",list_ch[i][0],list_ch[i][1]);
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
What does this mean?
list_ch[i][0],list_ch[i][1]);
"i" is the loop variable that allows you to access the values in the array.
Like:
Code:array[10]; int k; for(k = 0; k < 10; k++) { array[k] = k; //<--"k" is at "4" on the fifth go-around //....................// So if I assign the VALUE of "k" to the value in the //...................// array, then array[4] ==4 ! } for(k = 0; k < 10; k++) { printf("%i", array[k]); // <--See for yourself }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Ok I understand that the loops, but I mean what do the list_ch[i][0],list_ch[i][1]); mean you know how it has a zero right next to the "i".
In C the array indexing starts from 0.
FOr eg.,
if you declare
int a[10];
since the array starts from 0 the elements are
a[0],..............,a[9]any code containing a[10] might crash.
but If I am not mistaken it is legal to assign a pointer one past the end of a array
int a[10];
int p;p=a+10; /*probably legal*/
*p;/*illegal*/
I meant
int a[10];
int *p;
p=a+10;/*probably legal*/
*p;/*illegal*/