我想把我写的内容变成大写。但我不知道该怎么做。 这是我的代码:
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
int main(){
char buffer[50];
int retorno, leido, c;
while( (leido = read(0,&buffer,sizeof buffer)) > 0){
retorno = write(1,&buffer,leido);
}
printf ("valor de retorno: %d\n", retorno);
if (retorno<0){
return -1;
}
return 0;
}
最佳答案
您需要toupper
每个字符,例如
while( (leido = read(0,&buffer,sizeof buffer)) > 0){
for (int i=0; i<leido; i++) {
buffer[i] = toupper((unsigned char)buffer[i]);
}
retorno = write(1,&buffer,leido);
}
关于c - 如何在此代码中使用函数 toupper() ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49741894/