Having an error on strcpy "address pointing at code space is taken" [closed]
#pragma inspect, symbols
#pragma nolist
#pragma ENV LIBSPACE
#include <stdio.h>
#include <string.h>
#include <tal.h>
#include <cextdecs(FILE_OPEN_,FILE_CLOSE_,FILE_GETINFO_,FILENAME_DECOMPOSE_,WRITEX,READX,FILE_SETKEY_,WRITEUPDATEX,FILENAME_RESOLVE_,FILE_SETPOSITION_,PROCESS_GETINFOLIST_,USER_GETINFO_,FILENAME_MATCH_)>
#include <fcntl.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include "$SYSTEM.ZSYSDEFS.ZSYSC (filename_constant,process_itemcodes)"
#pragma list
/*VARIABLES*/
const char program_id_DB[] = "CSRTST";
const char program_name_DB_c[ZSYS_VAL_LEN_FILENAME] = {"$DSMSCM.CSR.CSRTST"};
/*PROCESS COMMAND FUNCTION*/
processCMD(char string[])
{
struct local_stack_def{
_cc_status cc;
char command_E[30];
char DataEntry[200];
char user_id_E[200];
char curr_vol_subvol[ZSYS_VAL_LEN_FILENAME];
char program_name_DB[ZSYS_VAL_LEN_FILENAME];
short ret_attr_count;
short ret_values_maxlen;
short user_maxlen;
char curr_vol_subvol_t;
int x, j, val1, val2, val3;
short user_curlen, piece_length, fullname_length;
short fpointer, error, resultFD,resultFM, resultUGI,resultGIL, resultFR,ret_val_length;
union {
long id_32;
short id_16[2];
} user_id;
struct {
short paid;
short prgm_len;
char prgm_name_E[ZSYS_VAL_LEN_FILENAME];
} ret_vals;
struct {
char val[20];
} command_DB[2];
struct {
char val4[50];
} user_id_DB[2];
sh开发者_StackOverflow社区ort attr_listX[2];
};
struct local_stack_def l_temp;
struct local_stack_def *l = &l_temp;
strcpy(&l->curr_vol_subvol_t,"x");
curr_vol_subvol_t
is declared to be char
. You can't copy a null-terminated C string "x"
into a single char
. You need a char
array with at least 2 members, or you can just assign a char
(e.g. 'x'
) to curr_vol_subvol_t
if that's what you really want.
Your curr_vol_subvol_t
is a single char
, but you're trying to write a char[2]
(namely { 'x', '\0' }
) to it. Don't do that. Just say l->curr_vol_subvol_t = 'x'.
精彩评论