gpt4 book ai didi

Code::blocks 中的代码在 Visual Studio 2013 中不起作用

转载 作者:行者123 更新时间:2023-11-30 15:15:37 26 4
gpt4 key购买 nike

这是我的代码:

// SysProAss1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <ctype.h>


int _tmain(int argc, _TCHAR* argv[])
{
{

char line[20];

//Asking the User to input some characters to use in the program
printf("Enter a few characters please:\n");
scanf_s("%s", line);

//For loop to print each character of the string on a new line
for (int i = 0; line[i]; ++i)
{
// If statement to check whether the character is an upper case vowel
if (line[i] == 'A' || line[i] == 'E' || line[i] == 'I' || line[i] == 'O' || line[i] == 'U')
printf("%c is an upper case vowel.\n", line[i]);

// If statement to check whether the character is a lower case vowel
else if (line[i] == 'a' || line[i] == 'e' || line[i] == 'i' || line[i] == 'o' || line[i] == 'u')
printf("%c is a lower case vowel.\n", line[i]);

// ispunct() function used to check whether the input character is a punctuation
else if (ispunct(line[i]))
printf("%c is a punctuation character. \n", line[i]);

// Else statement to print the character if it does not fit the above if statements
else
printf("%c\n", line[i]);

}

}

}

代码将编译,但当我输入字符时,不会打印任何内容。我已经测试过输入一些字符后字符串是否包含任何内容,但事实并非如此。如有任何帮助,我们将不胜感激

最佳答案

将代码中的 scanf_s 语句更改为 scanf_s("%s", line, sizeof(line));

关于Code::blocks 中的代码在 Visual Studio 2013 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33497537/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com