如何允许用户输入文本并将文本更改为其他值。 [英] How do I allow a user to input a text and changes the text to another value.

查看:88
本文介绍了如何允许用户输入文本并将文本更改为其他值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让用户输入一组文本,并使用只有字母的文本,我将如何阅读文本并将每个字母移动到下一个更改文本的值?

例如,字母a将更改为b,b将更改为c。

How do I make user input a set of text and using the text which has only alphabet letters how would I read the text and move each letter to the next changing the value of the text?
For example the letter a would change to b and b would change to c.

推荐答案

C 字符串是字符阵列。您可以简单地迭代数组项,递增所有数组,例如



C strings are character arrays. You might simple iterate over the array items, incrementing all of them, e.g.

#include <stdio.h>

int main()
{
  char s[] = "foo";
  char * p;

  for  ( p=s; *p; ++p )
    (*p)++;

  printf("%s\n", s);
  return 0;
}


这篇关于如何允许用户输入文本并将文本更改为其他值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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