d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Another Problem In C > Reading From File Into An Array Of Point
Prev12
Add Reply New Topic New Poll
Member
Posts: 3,210
Joined: Aug 21 2010
Gold: 152.00
Dec 8 2012 10:27pm
All right and this should allow me to pass the pointer of the array of pointers of floats to a function where floats can be read into it from a text file right?

Member
Posts: 3,210
Joined: Aug 21 2010
Gold: 152.00
Dec 8 2012 11:02pm
Nvm I got it to work so far...I will probably make another post if I run into the struct implementation

This assignment is so abstract and poorly explained I really appreciate you guys!

Thanks

Here's what I did:

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

void getData(float **);

int main() {

float* array1[20];

int i;

for(i = 0; i < 20; i++){

  array1[i] = malloc(sizeof(float));

}

float **arrayP;

arrayP = array1;

getData(arrayP);

return 0;
}


void getData(float **arrayPF) {

int x;

float check;

FILE *fp;

fp = fopen("FloatNums.txt", "r");

 do {

 fscanf(fp, "%f", arrayPF[0]);

 printf("%.2f\n", *arrayPF[0]);

}while ((x = fgetc(fp)) != EOF);

fclose(fp);

}


This post was edited by Nom_Nomz on Dec 8 2012 11:27pm
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll