strtok and while loop

조회 수: 1 (최근 30일)
Unkown one
Unkown one 2018년 4월 12일
댓글: Walter Roberson 2018년 4월 12일
Hello I'm new in Matlab I need to write a program that makes the user to input a sentence and then prints each word on a separate line after converting its characters to uppercase using while loop and strtok function. How could I do that? I wrote this but still I got an error.
f=input('Enter a sentence: ');
a=[];
while length(f)~=0
[f, r] = strtok(f);
a=[a upper(f) 10];
f=r;
end
disp(a);
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2018년 4월 12일
What have you tried so far? Have you looked at the documentation to see how you might request an input string from the user? What does the documentation say on using while or strtok?
Walter Roberson
Walter Roberson 2018년 4월 12일
f=input('Enter a sentence: ', 's');

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by