Shreyas - according to strcat, for _ character array inputs, strcat removes trailing ASCII white-space characters: space, tab, vertical tab, newline, carriage return, and form feed_. So your space is being removed by this function. Just use the square brackets for the string concatenation. For example, your callbacks can be simplified to
function h_Callback(hObject, eventdata, handles)
str = get(handles.text1,'String');
set(handles.text1,'String',[str 'h']);
function space_Callback(hObject, eventdata, handles)
str = get(handles.text1,'String');
set(handles.text1,'String',[str ' ']);
Try the above and see what happens!
Best Answer