I have fixed this problem and am now able to print the amount of samples and the maximum amplitude, however I am not sure where to start to put in some code to calculate the RMS value of all of the samples.
do you know how to calculate the RMS value of a large amount of samples?
int main (void)
int counter = 0;
float total = 0;
float max_amplitude = 0;
input1 = fopen("data-01.txt", "r");
if (input1 == NULL)
fprintf(stderr, "data-01.txt : Can't open file.\n");
while (fscanf(input1, "%f", &n) == 1)
total += n;
for(i = 0; i < counter; i++)
if(n > max_amplitude)
max_amplitude = n;
sprintf(data01, "%d samples, Amplitude = %f RMS = ", counter, max_amplitude);