如下這段代碼,放在一個.c檔案中,Windows下用gcc編譯可以通過,但放在一個.cpp檔案中Windows下用g++編譯報錯:error: 'strtok_s' was not declared in this scope
#include <string.h>
#include <stdio.h>
char string[] =".A string\tof ,,tokens\nand some more tokens";
char seps[] = " .,\t\n";
char* token = NULL;
char* next_token = NULL;
int main(void)
{
printf("Tokens:\n");
// Establish string and get the first token:
token = strtok_s(string, seps, &next_token);
// While there are tokens in "string1" or "string2"
while (token != NULL)
{
// Get next token:
if (token != NULL)
{
printf(" %s\n", token);
token = strtok_s(NULL, seps, &next_token);
}
}
printf("the rest token1:\n");
printf("%d", token);
}
請問這是為什么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/195514.html
標籤:C++ 語言
上一篇:【C語言求助】關于素數
下一篇:楊輝三角問題代碼,求助!
