【发布时间】:2018-08-14 05:44:39
【问题描述】:
您好,我想在 C 中创建一个包含 6 个元素的字符串数组。
示例:
我想保存名字、姓氏、账号、密码、lastTransaction、余额等信息。
我知道如何在 C# 中执行此操作,但无法使用 C 和 char[] 数组来理解它。
我希望输出是 userAccount[0][0] Joe, userAccount[0][1] Bloggs, userAccount[0][2] 123456, userAccount[0][3] 1234, userAccount[0][ 5] 8 月 14 日,userAccount[0][0] 4.25 美元。
【问题讨论】:
-
char *arr[] = {"one", "two", "three", ...};,这是一个指针数组,指向不可修改的chars,或char arr[][256] = {"one", "two", "three", ...};用于可修改的数组(256 是数组中每个字符串的最大长度)