Sample Input:o
0 4 0 5 0 8 0 7 0
Press any key to continue . . .

This is what I have so far for the code
[

#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE  81

int nArray[ARRAY_SIZE];

/*Function prototypes */
void PopulateArray( int nArray[9][9]);

void PrintArray(const  int nArray[9][9]);

void PopulateArray( int nArray[9][9])
{
   int i;
   int nSize;
   for(i=0 ; i < nSize ; i++)
   {
      printf("Enter value number %d:", i+1);
      _flushall();
      scanf("%d",&nArray[i]);
      
   }
      
}

void PrintArray(const int nArray[9][9])
{
   int i,j;
   
   for(i = 0; i <= 8 ; i++)
    {
   for(j = 0; j <= 8 ; j++)
      {
        printf("%2d",nArray[i][j]);
      }    
        printf("\n");
    }      
}  

int main(void)
{
  PopulateArray( int nArray[9][9]);
 
 PrintArray(const int nArray[9][9]);

 system("PAUSE");
 
 return 0;
}

I am getting the following errors in VC++

-------------------Configuration: Test - Win32 Debug--------------------
Compiling...
myfiletesting.c
C:\Documents and Settings\HP_Administrator\myfiletesting.c(16) : warning C4029: declared formal parameter list different from definition
C:\Documents and Settings\HP_Administrator\myfiletesting.c(28) : warning C4028: formal parameter 1 different from declaration
C:\Documents and Settings\HP_Administrator\myfiletesting.c(44) : error C2143: syntax error : missing ')' before 'type'
C:\Documents and Settings\HP_Administrator\myfiletesting.c(44) : error C2198: 'PopulateArray' : too few actual parameters
C:\Documents and Settings\HP_Administrator\myfiletesting.c(44) : error C2059: syntax error : ')'
C:\Documents and Settings\HP_Administrator\myfiletesting.c(46) : error C2143: syntax error : missing ')' before 'type'
C:\Documents and Settings\HP_Administrator\myfiletesting.c(46) : error C2198: 'PrintArray' : too few actual parameters
C:\Documents and Settings\HP_Administrator\myfiletesting.c(46) : error C2059: syntax error : ')'
Error executing cl.exe.

myfiletesting.obj - 6 error(s), 2 warning(s)

The following code should do the trick. Its not the most elagnant code as there is no validation for user inputs.

Also i have kept the interger array a 2 dimentional, if you want u can use a single dimentional array too (with approp changes), but keep it single dimentional across your as it makes the code more readable.

#include <stdio.h>

#define NROWS 3
#define NCOLS 3

static void popArray(int arr[NROWS][NCOLS])
{
	int rNo, cNo;

	for (rNo=0; rNo<NROWS; rNo++) {
		printf ("\nEnter row%d (%d values):", rNo, NCOLS);	//put approp message
		for (cNo=0; cNo<NCOLS; cNo++) {
			scanf("%d", &(arr[rNo][cNo]));
		}
	}
}


static void printArray(int arr[NROWS][NCOLS])
{
	int rNo, cNo;

	for (rNo=0; rNo<NROWS; rNo++) {
		printf("\n");
		for (cNo=0; cNo<NCOLS; cNo++) {
			printf("%d ", arr[rNo][cNo]);
		}
	}
}


int main(void)
{
	int myArr[NROWS][NCOLS];

	popArray(myArr);
	printArray(myArr);

	return 0;
}

-------------------Configuration: Test - Win32 Debug--------------------
Compiling...
myfiletesting.c
C:\Documents and Settings\HP_Administrator\myfiletesting.c(16) : warning C4029: declared formal parameter list different from definition
C:\Documents and Settings\HP_Administrator\myfiletesting.c(28) : warning C4028: formal parameter 1 different from declaration

Look at the lines specified. You are calling a function, but the parameters do not match the prototype you specified, such as calling with a char and the parameter needs a char*

C:\Documents and Settings\HP_Administrator\myfiletesting.c(44) : error C2198: 'PopulateArray' : too few actual parameters

Isn't this one obvious?

C:\Documents and Settings\HP_Administrator\myfiletesting.c(44) : error C2059: syntax error : ')'

Look at the line. Why would the errer point out a ')'?


-------

The following code should do the trick. Its not the most elagnant code as there is no validation for user inputs.

What grade are you expecting for finishing his code for him? We prefer to help them solve the problems, not prove we can do better... :icon_wink:

Be a part of the DaniWeb community

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