2013年8月11日 星期日

[C/C++基礎]利用strstr實現字串替換(rtsp to http string)

[C/C++基礎]利用strstr實現字串替換(rtsp to http string)



本篇要分享-利用strstr實現字串替換(rtsp to http string),有興趣的(C/P)同好,歡迎來(C/P)一下哈哈 ^ ^。









 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MEDIAPATHMAXLENGTH 256

static
char g_acMediaPlayerOne[MEDIAPATHMAXLENGTH];
/*
strcpy(g_acMediaPlayerOne, "http://jashliao.pixnet.net/blog/smooth/videos/drama_w1240k.mp4/playlist.m3u8?name=jash.liao");
g_eMediaPlayerMode = eMediaPlayerMode_playone;
*/

int
rtsp2httpfun();
int
main()
{

//http playlist.m3u8
//0 0
strcpy(g_acMediaPlayerOne, "rstp://jashliao.pixnet.net/blog/smooth/videos/drama_w1240k.mp4?name=jash.liao");
rtsp2httpfun();
//0 1
strcpy(g_acMediaPlayerOne, "rstp://jashliao.pixnet.net/blog/smooth/videos/drama_w1240k.mp4/playlist.m3u8?name=jash.liao");
rtsp2httpfun();
//1 0
strcpy(g_acMediaPlayerOne, "http://jashliao.pixnet.net/blog/smooth/videos/drama_w1240k.mp4?name=jash.liao");
rtsp2httpfun();
//1 1
strcpy(g_acMediaPlayerOne, "http://jashliao.pixnet.net/blog/smooth/videos/drama_w1240k.mp4/playlist.m3u8?name=jash.liao");
rtsp2httpfun();
return
0;
}

int
rtsp2httpfun()
{

char
*pchrcheckdata="playlist.m3u8";
char
* pch='\0';
pch = strstr (g_acMediaPlayerOne,pchrcheckdata);
printf("rtsp2httpfun g_acMediaPlayerOne before: %s\n",g_acMediaPlayerOne);
if
(pch)
{

g_acMediaPlayerOne[0]='h';
g_acMediaPlayerOne[1]='t';
g_acMediaPlayerOne[2]='t';
g_acMediaPlayerOne[3]='p';
printf("rtsp2httpfun g_acMediaPlayerOne after: %s\n",g_acMediaPlayerOne);
return
1;
}

printf("rtsp2httpfun g_acMediaPlayerOne after: %s\n",g_acMediaPlayerOne);
return
0;
}

 


 


沒有留言:

張貼留言