I have been working on a HW assignment for a while and I cant figure out how to print out a 'user' selected column out of an array. I can print the rows, but I need to know how to print specific columns dictated by user input.

My code is below.

void showRow(int* array, int = 10){
     int i;
     printf("Running showRow/n");
     for(i=0; i<10; i++){
     printf("%d ,", array[i]);

int main()
    int numArray [10][10], row, col, count = 0;
    int x = 3;
    int *xptr; 
   int *rowptr = &j;
   int *colptr = &k;
   for (row=0; row<10; row++){       
             for(col=0; col<10; col++){
                     numArray[row][col] = count++;
    printf("pass each row\n");
/*passing each row to my showRow function*/
    for(row=0; row<10; row++){
        showRow(numArray[row], 10);
    return 0;
Here is where I am having my trouble. In class we developed a formula to search through the array for our 'col' values
- *((xptr + row * number of Col per row) + col) -
I expect that I need to create a for loop in a for loop to cycle through the rows to find the col's.  
And then call the equation.
And then set up my print.
But I dont know what syntax i would use to print!??
    for (row=0; row<10; row++)

I would apprecaite any help. Thanks

Well to print a row you would hold the row index constant and then vary the column from 0 - max_column...So to print a column you would hold a column constant and vary the row from 0 - row_max.

For row 2, i varies from 0 - max_column


for column 3, i varies from 0 - max_row


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.