Hello everyone,
I am currently working on my function of counting space characters, it works well if my text file has only 1 line but it messes up when i input multiples lines into my file. Could anyone please tell me what I am doing wrong?
function space = swap(file)file = 'mytext.txt';f = fopen(file, 'rt');while feof(f) == 0s = fgetl(f);a = length(strrep(s, ' ', ''));b = length(s);space = b - a;endend
Best Answer