利用字符串的指针打印的字符组合的整数 [英] making use of string pointer to print the character-integer combinations

查看:166
本文介绍了利用字符串的指针打印的字符组合的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有C函数接受字符串指针作为参数。这个功能返回如符号是由该指针指向。我想生成取决于需求=很多符号。假设,我有四个门的房子。我想给不同的名称不同的门像 D1,D2,D3 ...... 。在这种情况下,我想创建一个字符串指针,它指向字符串和整数,这样我就可以得到它通过只数值不同的符号。这有助于我看到分类的字符串值的符号。我想知道我可以声明一个字符串指针,这样我可以创造我上面提到的象征。

I have C function that takes string pointer as a parameter. This functions returns as symbol which is pointed by the pointer. I would like to generate = many symbols depending upon the requirements. Suppose, i have four doors in a house. I would like to give different names to different doors like d1,d2,d3..... In this case , i would like to create a string pointer which points to both string and integer so that i can get the symbols which differ by only numerical values. This helps me to categorize the symbols seeing the string value. I would like to know how can i declare a string pointer so that i can create a symbol that i mentioned above.

我会尽量说清楚。

我有两个指针数组

const char *test[] ={"a","12345"}

我想使指针指向一个1和和2 ....等等。有没有什么方法呢?

I would like make the pointer to point a and 1 and a and 2 and .... so on. Is there any method to do it?

推荐答案

既然问题是如此暧昧,这里是另一个之一:

Since the question is so ambiguous, here's yet another one:

#include <stdio.h>

int main(int argc, char *argv) {
    const char *test[] = { "a", "12345" };

    int i, j;

    for (i = 0; test[0][i] != 0; ++i)
        for (j = 0; test[1][j] != 0; ++j)
            printf("%c%c\n", test[0][i], test[1][j]);

    return 0;
}

输出:

a1
a2
a3
a4
a5

这篇关于利用字符串的指针打印的字符组合的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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