Greetings.
I am pretty new to C-programming since I just started 2 weeks ago. I though think its very fun and like to be better at it.
I found something hard to prgram, since I have no idea how it should be written.
Ill try to explain what I did untill now and what I cant get to work.
I have a textfile temperatur.txt with 31 temperatures looking like this:
1 2 5 3 -2 0 2 1 0 4 3 2 0 1...
Another textfile with downpour.txt
-2 2 3 4 1 2 0 0 0 3 5 2 1 0 0 2...
Both files with 31 numbers in.
I loaded both files in with FILE*prt and prt..... scanf.... etc. This is working.
I need to find where there aint no downpour, and find the dates and temperatur for this.
So im setting downpour09[i] == 0, then I know the i´s is the dates and temptabel09[i] is the temperatur those days.
this is the program:
Code:
for (i = 0; i < 31; i++)
if(downpour09[i] == 0) //find where there aint no downpour.
{
printf("Date[%d]Temperatur[%.f ]\n",i,temptabel09[i]);
}
The output is:
Date[2] Temperatur[-2]
Date[1] Temperatur[-3]
Date[-2] Temperatur[-4]
Date[4] Temperatur[-1]
Date[1] Temperatur[0]
But I would like the output to be like a Matrix.
Date 2 temperatur -2
Date 1 temperatur -3
Date -2 temperatur -4
Date 4 temperatur -1
Date 1 temperatur -0
you see my point?
I tried with a simple matrix:
Code:
void main()
{
int matrix[3][2];
int i,j;
for (i = 0 ; i < 3; i++)
{
for(j = 0;j < 2;j++)
{
matrix[i][j]=tal;
tal++;
printf("%d",tal);
}
}
}
the output is: 123456
But I want the output to be
1 2
3 4
5 6
How?
I hope I explained it right and its not to long.
Cheers.