0
這裏不工作是我的代碼:代碼在代碼::塊在Visual Studio 2013
// 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]);
}
}
}
的代碼可以編譯,但是當打印我的輸入字符什麼。我已經測試過,看看輸入一些字符後字符串是否包含任何內容,而不是。任何幫助將appriciated
'scanf_s( 「%s」 時,線);'需要的大小 - >'scanf_s( 「%S」 線,20) ;' – BLUEPIXY
是的,現在工作,非常感謝。我覺得有點愚蠢:) – Tom
請問我可以如何實現另一個if語句,以便能夠識別重複字符,例如。 b,b - 重複字符。 – Tom