MATLAB: How to find the number of character in a text file

homeworkMATLABstringstext fileutf

I have a text file 'inp.txt' containing one line like this:
'banerjee.raktim 123456789125'
I want to know the number of character present in this line, including the white space. And also want to know the position of the white space character.
The expected no of character is 28 and opsition of space is:
16
How to do this?

Best Answer

fid = fopen('inp.txt'); % see also fclose
A = char(fread(fid,inf)).';
A =
banerjee.raktim 123456789125
>> length(A)
ans =
28
>> strfind(A,' ')
ans =
16