Tool/software: Code Composer Studio
Hello,
I am trying to read a .CSV file (I first open an excel file and paste my data and save as .csv file). The filedata.xlsxattached below is an .xlsx file as I can't attacht a csv file here. But I made made the csv file using the same file. My target is reading the file and storing all 500 data (data are like 4095, 2000, 3462, 1298 and so on) in an array. But the data I am getting is not exactly what I stored in the file. Below is my code.Anyone please help me understand what I am doing wrong here:
#include <msp430.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
char in_value[500], strin;
unsigned int input [500];
FILE* fp;
fp = fopen ("data1.csv", "r");
int i=0;
while(fgets(in_value,500,fp)!=NULL)
{
fscanf(in_value[i],"%s",strin);
input [i]= atoi(strin); // getting back random values like 25591, 45673, 8246583, 4535....
if(in_value[i]=="\n")
i=i+1;
}
fclose(fp);
Thanks