如何输入打印下一个字符的程序[C ++] [英] How do I type a program that prints the next character [C++]

查看:88
本文介绍了如何输入打印下一个字符的程序[C ++]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如当我从字母表中输入一个字符时它会给我下一个字符

i不希望代码在cout中cin我希望它在printf和scanf中尝试下面的代码,但它没有用。



我尝试过:



for example when i type in a character from the alphabet it gives me the next one
i don't want the code to be in cout and cin i want it to be in printf and scanf i tried the code below but it didn't work.

What I have tried:

#include <stdio.h>
int main ()
{ 
char z;
scanf("%c",&z);
printf("%c",z+1);
return 0 ;
}

推荐答案

这是一个学习C / C ++基础知识的好讲座

C编程语言 - 维基百科,免费的百科全书 [ ^ ]

https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf [ ^ ]

http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf [ ^ ]



C ++编程语言 [ ^ ]
Here is a good lecture to learn C/C++ basics
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]

C++ Programing Language[^]


这完全有效。测试代码, C ++ Shell [ ^ ]。您在对该问题的评论中提到了以下内容。

That works just perfectly. Tested the code at, C++ Shell[^]. You mentioned the following in a comment to the question.
引用:

在visual studio中

in visual studio

在Visual Studio中你不能使用不安全的代码,不安全我的意思运行时未正确处理的代码。 Visual Studio建议使用 scanf_s 而不是 scanf 。这是您可能面临的问题。



出于学习目的,Visual Studio不是我的个人推荐。我建议使用GCC编译器来实现C语言。您可以使用终端和文本编辑器来学习C语言。 GCC不会像Visual Studio那样粗鲁。 Visual Studio需要很多东西,只是警告,并在编译时将它们塑造并显示为错误。那时候,你会开始相信你的源代码可能有问题。



注意 _s 安全 运行时中函数的变体。有关详细信息,请参阅 c ++ - 为什么VS2013告诉我使用scanf_s? - 堆栈溢出 [ ^ ]

In Visual Studio you cannot use unsafe code, by unsafe I mean the code that is not properly handled by the runtime. Visual Studio recommends using "scanf_s" instead of the "scanf". That is the problem that you might be facing.

For learning purposes, Visual Studio is not my personal recommendation. I recommend using GCC compiler for C language. You can use the terminal and a text editor, to learn the C language. GCC won't be as much rude as Visual Studio is. Visual Studio takes many things, that just warnings, and molds them and shows them as errors at compile time. That is when, you will start believing that maybe your source code has issues.

Note: _s are the "secure" variants of the functions in the runtime. For more on it, see, c++ - Why is VS2013 telling me to use scanf_s? - Stack Overflow[^]


这篇关于如何输入打印下一个字符的程序[C ++]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆