Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reading a value in a string

0 views
Skip to first unread message

Nhan Nguyen

unread,
Feb 9, 2010, 8:09:05 PM2/9/10
to
lets say I got a string C = "this is for testing1", how do I get that value 1 in that string into an integer? I know I can find the length(C) then what? There's fgets and fread but I don't know how to setup those functions up to find that value 1 at the end of that string.

ade77

unread,
Feb 9, 2010, 8:43:04 PM2/9/10
to
"Nhan Nguyen" <nepth...@gmail.com> wrote in message <hkt0vh$ko9$1...@fred.mathworks.com>...

> lets say I got a string C = "this is for testing1", how do I get that value 1 in that string into an integer? I know I can find the length(C) then what? There's fgets and fread but I don't know how to setup those functions up to find that value 1 at the end of that string.

For your specific example:
C = 'this is for testing1'
h = C(end)
answer = str2num(h)

0 new messages