【发布时间】:2016-10-20 16:18:45
【问题描述】:
我是 C 新手。我有这样的代码
#include <stdio.h>
#include <string.h>
int i = 0;
int main()
{
char text[] = "..... $it is beautiful : $yes you are correct....";
char * sub = "$";
char * ret = strstr(text, sub);
if (ret != NULL)
{
printf("the statement is : %s", ret);
}
}
我只想打印这部分代码:$it is beautiful。
有没有办法只打印那个语句?让我们假设这是全文的一部分,那么除了使用 strlen 之外还有什么想法吗?
当出现第二个$ 时不应该出现打印。这是我的基本要求
【问题讨论】:
-
你现在得到什么印刷品?
-
$它很漂亮:$是的,你是对的....这是打印输出