i have a 2d array that's array[10][10] and a double number. I want to put that number into the 1st line of the array how will i do that?

array[0]=number; does not work, is there a simple way of converting it?

for instance

double number;
double list[10][10]
number=5.35
i want to make
list[0] = 5.35 basically filling the first line. Please help, thanks

Heres the code that i tried

#include <stdio.h>

int main ()
{
char word[10][10];
double num;
double number[10][10];
FILE*myin;
myin=fopen("first.dat","r");
fscanf(myin,"%s",&word[0]);
fscanf(myin,"%lf",&num);
printf("%s\n%lf",word[0],num);
number[0]=num;
fclose(myin);
return(0);
}

This thread might clear things up.

i'm still confused, the thread sets an array = to another array, what i want to do is set an array = to a (double) number

If what you mean is that you want to fill list[0][0] through list[0][9] with 5.35f, then use a for loop and assign 5.35f to each int from 0 through 9 on row 0.

You define the TWO 2D arrays, but then you handle them like 1D vectors. Is that what you want to do?

double number[10][10];

. . .

number[0]=num;

. . .

If you want to assign num to array element (0,0), you should state it like this:

number[0][0]=num;

thanks, i somehow got it fixed!

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.