MATLAB: Are spaces ignored when a character string is scanned

character stringfscanfMATLAB and Simulink Student Suite

So I have a file titled text.txt which contains the string, 'Hi There!'. Now, when I use the following code to extract the string into my variable, data, MATLAB seems to ignore the space in the string.
%% Code Snippet
fileName = 'text.txt'; %name of file containing the data to be sent
formatSpec = '%s'; %data type
fileID = fopen(fileName,'r');
% data = textscan(fileID,formatSpec);
data = fscanf(fileID,formatSpec);
fileID = fclose(fileID);
%%
So, when I try to check the contents of 'data' in the command prompt:
>> data
data =
'HiThere!'
How do I make MATLAB scan the spaces in my character string?

Best Answer

"How do I make MATLAB scan the spaces in my character string?"
Use the character format spec
formatSpec = '%c'; %data type
Alternatively,
data = fileread('text.txt');