W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
#include <stdio.h>
#include <string.h>
​
struct myStructure {
  int myNum;
  char myLetter;
  char myString[30];  // 字符串
};
​
int main() {
  struct myStructure s1;
​
  // 使用 strcpy 函数为字符串赋值
  strcpy(s1.myString, "Some text");
​
  // 打印字符串值
  printf("字符串内容: %s", s1.myString);
​
  return 0;
}