是否可以在PIC C编译器中使用字符串C?

问题描述 投票:-2回答:1

如何在string中使用CCS

我可以使用:

string myString = "My String"; // Error

或不是?

c++ c pic
1个回答
5
投票

标准string.h头文件确实not定义了一种称为string的数据类型,它提供了用于处理C样式字符串的函数,这些字符串是空终止的字符数组。

例如,您可以执行以下操作:

#include <stdio.h>
#include <string.h>
int main(void) {
    char *myName = "paxdiablo";
    printf("Length of '%s' is %zu\n", myName, strlen(myName));
    return 0;
}

请注意该代码中的字符串,它是指向paxdiablo字符串文字的指针,not标准未提供的某些string类型。


C ++ does提供std::string类型,但是在C ++ string标头中,而不是C string.h中。无论如何,从他们的web presence看来,CCS并没有提供C ++编译器,而是专注于C市场。

© www.soinside.com 2019 - 2024. All rights reserved.