Write a getString() function that prompts the user for a string and returns it

Call getString() function to get the string from the user. I can't get the string from the function.
function getstring()
input('Enter A String: ','s');
end

 Akzeptierte Antwort

function str = getstring()
str = input('Enter A String: ','s');
end

3 Kommentare

sir I am asked to call getstring and the call function testpalindromes which uses getstring as a string and tests the string here is my code can plz correct my mistakes
function testpalindromes()
if strcmpi(str,fliplr(str))
fprintf('yes %s is a palindrome \n',str)
else
fprintf('no %s is not a palindrome \n',str)
end
it is working right...
Yes It is working But it is not using the getstring function to test

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Debugging and Analysis finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by