''DepPrd:$#Iden1:N$#Abst:$#NumOfDys:0$#FSubCode1:$#AgntCtfTp:$#Ccy:CNY$#Wher:00$#CtfNum2:632823195205100014$#CtfTp :01$#AmtOfMny:400000.00$#CtfNum:$#Flg5:0$#CtfNum3:632823195205100014$#AgntIdNum:$#CodeC:5050$#ChkAgtName:$#AhrName:CNY$#BalA:0$#Cani:CNY$ #AcNum:81020000020245126$#Cgy2C:0112$#Cyce2C:$#IdentTp:01$#Code3C:$#AmtOfMny4:0$#Name1:哇保$#Tp6:01$#Cyce:$#BnkAc:0$#Tp1 :1121$#AgntTel:$#Name:$#AcNum1:$#Attr4:029$#IdentTp1:$#DocTp:$#SerialNum5:$#Code4C:$#DebugQueue:$#CZ_JRNL_NO_1:''用$#切割之后变成键值对
时间: 2023-09-13 10:10:24 浏览: 89
好的,根据您的要求,我将字符串用$#分割成多个键值对:
- DepPrd:
- Iden1: N
- Abst:
- NumOfDys: 0
- FSubCode1:
- AgntCtfTp:
- Ccy: CNY
- Wher: 00
- CtfNum2: 632823195205100014
- CtfTp: 01
- AmtOfMny: 400000.00
- CtfNum:
- Flg5: 0
- CtfNum3: 632823195205100014
- AgntIdNum:
- CodeC: 5050
- ChkAgtName:
- AhrName: CNY
- BalA: 0
- Cani: CNY
- AcNum: 81020000020245126
- Cgy2C: 0112
- Cyce2C:
- IdentTp: 01
- Code3C:
- AmtOfMny4: 0
- Name1: 哇保
- Tp6: 01
- Cyce:
- BnkAc: 0
- Tp1: 1121
- AgntTel:
- Name:
- AcNum1:
- Attr4: 029
- IdentTp1:
- DocTp:
- SerialNum5:
- Code4C:
- DebugQueue:
- CZ_JRNL_NO_1:
相关问题
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<windows.h> #include<string.h> #include<stdlib.h> #include<math.h> typedef struct character_name { char name[100]; struct character_name* next; }char_name; typedef struct character_title { char title[100]; struct character_title* next; }char_title; typedef struct character_identity { char identity[100]; struct character_identity* next; }char_iden; typedef struct character_profession { char profession[100]; int level; struct character_profession* next; }char_pro; typedef struct character_ability { char ability[100]; char explain[1000]; struct character_ability* next; }char_abi; typedef struct character_race { char race[100]; struct character_race* next; }char_race; typedef struct character_information { int age; int gender; char_name* _name; char_title* _title; char_iden* _iden; char_pro* _pro; char_abi* _abi; char_race* _race; struct character_information* next; }char_inf; char_inf* initialization() { char_inf* node = (char_inf*)malloc(sizeof(char_inf)); node->_name = (char_name*)malloc(sizeof(char_name)); node->_title = (char_title*)malloc(sizeof(char_title)); node->_iden = (char_iden*)malloc(sizeof(char_iden)); node->_pro = (char_pro*)malloc(sizeof(char_pro)); node->_abi = (char_abi*)malloc(sizeof(char_abi)); node->_race = (char_race*)malloc(sizeof(char_race)); return node; } char_inf* ceshi, * current, * end; char_name* name_current, * name_end; char_title* title_current, * title_end; char_iden* iden_current, * iden_end; char_pro* pro_current, * pro_end; char_abi* abi_current, * abi_end; char_race* race_current, * race_end; int main() { ceshi = initialization(); ceshi->age = 666; ceshi->gender = 1; name_current = ceshi->_name; strcpy(name_current->name, "ceshi_name_1"); name_current->next = (char_name*)malloc(sizeof(char_name)); name_current = name_current->next; name_current->next = NULL; strcpy(name_current->name, "ceshi_name_2"); strcpy(ceshi->_title->title, "ceshi_title"); strcpy(ceshi->_iden->identity, "ceshi_identity"); strcpy(ceshi->_pro->profession, "ceshi_profession"); strcpy(ceshi->_abi->ability, "ceshi_ability"); strcpy(ceshi->_abi->explain, "ceshi_ability_explain"); strcpy(ceshi->_race->race, "ceshi_race"); ceshi->_pro->level = 666; name_current = ceshi->_name; printf(" Age: %d\n", ceshi->age); printf(" Gender: "); if (ceshi->gender == 0) printf("woman\n"); else printf("male\n"); while (name_current != NULL) { printf(" Name: %s\n", name_current->name); name_current = name_current->next; } printf(" Title: %s\n Identity: %s\n Profession: %d\n Ability: %s\n Ability_Explain: %s\n Race: %s\n", ceshi->_title->title, ceshi->_iden->identity,ceshi->_pro->level,ceshi->_abi->ability,ceshi->_abi->explain,ceshi->_race->race); return 0; } 怎样可以消除取消对NULL指针的引用这个警告
要消除对NULL指针的引用警告,你可以使用以下方法:
1. 在编译时使用特定的编译选项或指令。例如,对于gcc编译器,你可以使用`-Wno-null-dereference`选项来禁用对NULL指针引用的警告。
```bash
gcc -Wno-null-dereference your_code.c
```
2. 使用编译指令来取消警告。在代码中,你可以使用特定的编译指令来取消对NULL指针引用的警告。在C语言中,你可以使用`#pragma`指令来实现。例如:
```c
#pragma GCC diagnostic ignored "-Wnull-dereference"
// 在这里写你的代码
#pragma GCC diagnostic warning "-Wnull-dereference"
```
这将在特定代码块中取消和重新启用对NULL指针引用的警告。
3. 针对特定行的警告,你可以使用条件语句来避免对NULL指针进行操作。例如,使用`if`语句检查指针是否为空。
```c
if (pointer != NULL) {
// 在这里进行指针操作
}
```
请注意,取消对NULL指针引用的警告可能会隐藏真正的问题,因此请谨慎使用此功能,并确保你了解代码中的潜在问题。
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<windows.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<malloc.h> typedef struct character_name { char name[100]; struct character_name* next; }char_name; typedef struct character_title { char title[100]; struct character_title* next; }char_title; typedef struct character_identity { char identity[100]; struct character_identity* next; }char_iden; typedef struct character_attribute { int strength; struct character_attribute* next; }char_att; typedef struct character_information { char_name* _name; char_title* _title; char_iden* _iden; char_att* _att; struct character_information* next; }char_inf; char_inf* initialization() { char_inf* node = (char_inf*)malloc(sizeof(char_inf)); node->_name = (char_name*)malloc(sizeof(char_name)); node->_title = (char_title*)malloc(sizeof(char_title)); node->_iden = (char_iden*)malloc(sizeof(char_iden)); node->_att = (char_att*)malloc(sizeof(char_att)); return node; } char_inf* ceshi, * current, * end; char_name* name_current, * name_end; char_title* title_current, * title_end; char_iden* iden_current, * iden_end; char_att* att_current, att_end; int main() { ceshi = initialization(); name_current = (char_name*)malloc(sizeof(char_name)); name_current = ceshi->_name; strcpy(name_current->name, "ceshi_1_1"); name_current->next = (char_name*)malloc(sizeof(char_name)); name_current = name_current->next; strcpy(name_current->name, "ceshi_1_2"); strcpy(ceshi->_title->title, "ceshi_2"); strcpy(ceshi->_iden->identity, "ceshi_3"); ceshi->_att->strength = 4; name_current = ceshi->_name; while (name_current->next != NULL) { printf("%s\n", name_current->name); name_current = name_current->next; } printf("%s\n%s\n%d\n", ceshi->_title->title, ceshi->_iden->identity, ceshi->_att->strength); return 0; } 为什么提示我访问权限报错
在你的代码中,提示访问权限错误的原因是你错误地给指针变量`att_end`赋值。
在`main`函数中,你声明了一个指向`char_att`类型的指针变量`att_end`,然后你尝试给它赋值。但是,在赋值的过程中,你漏掉了`att_end`指针变量前面的`*`,导致赋值操作实际上是在修改指针变量本身的值,而不是修改它所指向的内存。
为了解决这个问题,你需要在赋值语句中正确地使用`*`来解引用指针,如下所示:
```c
*att_current = *att_end;
```
请注意,在之前的代码中,你没有为`att_end`分配内存空间,因此在这里直接解引用可能会导致未定义行为。如果你需要为`att_end`分配内存并进行赋值操作,请确保在操作之前为它分配足够的内存空间。
修正后的代码如下所示:
```c
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<windows.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>
typedef struct character_name
{
char name[100];
struct character_name* next;
} char_name;
typedef struct character_title
{
char title[100];
struct character_title* next;
} char_title;
typedef struct character_identity
{
char identity[100];
struct character_identity* next;
} char_iden;
typedef struct character_attribute
{
int strength;
struct character_attribute* next;
} char_att;
typedef struct character_information
{
char_name* _name;
char_title* _title;
char_iden* _iden;
char_att* _att;
struct character_information* next;
} char_inf;
char_inf* initialization()
{
char_inf* node = (char_inf*)malloc(sizeof(char_inf));
node->_name = (char_name*)malloc(sizeof(char_name));
node->_title = (char_title*)malloc(sizeof(char_title));
node->_iden = (char_iden*)malloc(sizeof(char_iden));
node->_att = (char_att*)malloc(sizeof(char_att));
return node;
}
int main()
{
char_inf* ceshi = initialization();
ceshi->_name->next = NULL;
strcpy(ceshi->_name->name, "ceshi_1_1");
ceshi->_name->next = (char_name*)malloc(sizeof(char_name));
strcpy(ceshi->_name->next->name, "ceshi_1_2");
strcpy(ceshi->_title->title, "ceshi_2");
strcpy(ceshi->_iden->identity, "ceshi_3");
ceshi->_att->strength = 4;
char_name* name_current = ceshi->_name;
while (name_current != NULL)
{
printf("%s\n", name_current->name);
name_current = name_current->next;
}
printf("%s\n%s\n%d\n", ceshi->_title->title, ceshi->_iden->identity, ceshi->_att->strength);
return 0;
}
```
修正后的代码中,我也对代码的其他部分进行了一些调整和修正,以确保正确的运行。