File.available()

Hello Folks,

I am new to programming and I want to know how available() fuction works. My file is called TEST and it is in CSV format. I have three numbers that are seprated by commas and are as following: 11,222,333.
When I use the following code

#include <SD.h>

int CS_pin=4;
char reading[]="";
char *pstring= reading;
int availablebytes=0;

void setup()
{Serial.begin(9600);
if(!SD.begin(CS_pin))
{Serial.println("SD card failed to connect");
return;
}
Serial.println("we are good to go");
}

void loop ()
{
File TEST =SD.open("TEST.csv",FILE_READ);
if(TEST)
{
availablebytes= TEST.available();
Serial.print(availablebytes);
}}

I get the following:

we are good to go
9303930393039303930393039303930393039303..

what does 9303 stand for and how is this working?

Thank You for your help :slight_smile:

It looks to me as though there are 9303 bytes in the file and you are printing it over and over in the loop() function.

See SD - Arduino Reference

This is a great illustration of why anonymous prints are so stupid.

Imagine replacing that useless output with:

Serial.print("There are ");
Serial.print(availableBytes);
Serial.println(" bytes in the file.");

Would it have been necessary to ask what THAT output meant?