标签:tar sha print efi nbsp int char target stdin
首先判断你的机器汉字占几个字节
#include <stdio.h> int main() { char str[] = "中"; int length, i; length = sizeof(str) / sizeof(str[0]); printf("length of str: %d\n", length); for (i = 0; i < length; i++) { printf("str[%d] = %d\n", i, str[i]); } return 0; }
#include<stdio.h> #define MAX 1024 int main(){ char str[MAX]; char *target=str; char ch; int length=0; printf("请输入一个字符:"); fgets(str,MAX,stdin); while(1){ ch=*target++; if(ch==‘\0‘) { break; } if((int)ch<0){ target+=1; } length++; } printf("你输入了%d个字符",length-1); }
标签:tar sha print efi nbsp int char target stdin
原文地址:https://www.cnblogs.com/helloworld2019/p/11125755.html