Sep 13, 2009 at 7:28am UTC
i want print a particular part of string
for eg:
char ss[20]="i am the only bosss";
i want to print ss[3] to ss[7]
how can do this ?
help me please
thanks in advance
Update
if in C how can i ?
Last edited on Sep 13, 2009 at 8:08am UTC
Sep 13, 2009 at 8:02am UTC
1 2
for (int i = 3; i <= 7; ++i)
std::cout << ss[i];
There may be a function that does it for you but I don't know it.
Or you could use the string class which would probably be the best idea.
1 2 3 4 5 6 7 8 9
#include <iostream>
#include <string>
int main()
{
std::string ss = "i am the only bosss" ;
std::cout << ss.substr(3, 5) << std::endl;
return 0;
}
The first argument (3) is the starting position and the second argument (5) is the length of the substring.
Last edited on Sep 13, 2009 at 8:04am UTC