T
tntelle
I am having an issue with comparing two strings. I call two separate
functions to get each what should be the same thing. Everything looked
fine but the string compare failed. I put quotes around each and this
is what happens when I print the values:
VALUE1 = "THIS IS THE VALUE"
VALUE2 = "THIS IS THE VALUE
X"
The X ends up being one or two characters that are random and is on
the next line-- the value changes sometimes after I recompile.
I tried various things such as getting the string length of VALUE1,
creating a malloc variable and setting the array length to that value
and that did not help. I subtracted 1, 2 and so forth from the string
length of VALUE1, but the character is still there. I was thinking it
could be the null terminating character, but since every C string
should have that ( I am assuming) I figured that wasn’t it and I
should not try to remove that.
Here is the segment of code that is feeding VALUE2
(CKSUM_ATTRIBUTE = VALUE1, RETURN_CODE_2 = VALUE2)
BUFSIZE_2 = strlen(CKSUM_ATTRIBUTE);
char VARIABLES_2[256];
char *RETURN_CODE_2;
RETURN_CODE_2 = (char *)malloc(BUFSIZE_2);
unsigned int CKSUM_MATCH;
snprintf(VARIABLES_2, sizeof VARIABLES_2, "/usr/bin/cksum
'%s'",ARGV1);
FILE * f_2 = popen(VARIABLES_2, "r");
size_t r_2;
while((r_2 = fread(RETURN_CODE_2, sizeof(char), BUFSIZE_2 - 1, f_2))
}
pclose(f_2);
printf ("VALUE1: \"%s\"",RETURN_CODE_2);
printf ("VALUE2:: \"%s\"\n",CKSUM_ATTRIBUTE);
CKSUM_ATTRIBUTE already contains the output of calling cksum ARGV1,
that I have already confirmed, and RETURN_CODE_2 matches up until the
next line strange character situation.
I am lost for ideas and appreciate any guidance or idears. Thank you!
functions to get each what should be the same thing. Everything looked
fine but the string compare failed. I put quotes around each and this
is what happens when I print the values:
VALUE1 = "THIS IS THE VALUE"
VALUE2 = "THIS IS THE VALUE
X"
The X ends up being one or two characters that are random and is on
the next line-- the value changes sometimes after I recompile.
I tried various things such as getting the string length of VALUE1,
creating a malloc variable and setting the array length to that value
and that did not help. I subtracted 1, 2 and so forth from the string
length of VALUE1, but the character is still there. I was thinking it
could be the null terminating character, but since every C string
should have that ( I am assuming) I figured that wasn’t it and I
should not try to remove that.
Here is the segment of code that is feeding VALUE2
(CKSUM_ATTRIBUTE = VALUE1, RETURN_CODE_2 = VALUE2)
BUFSIZE_2 = strlen(CKSUM_ATTRIBUTE);
char VARIABLES_2[256];
char *RETURN_CODE_2;
RETURN_CODE_2 = (char *)malloc(BUFSIZE_2);
unsigned int CKSUM_MATCH;
snprintf(VARIABLES_2, sizeof VARIABLES_2, "/usr/bin/cksum
'%s'",ARGV1);
FILE * f_2 = popen(VARIABLES_2, "r");
size_t r_2;
while((r_2 = fread(RETURN_CODE_2, sizeof(char), BUFSIZE_2 - 1, f_2))
RETURN_CODE_2[r_2+1] = '\0';1) {
}
pclose(f_2);
printf ("VALUE1: \"%s\"",RETURN_CODE_2);
printf ("VALUE2:: \"%s\"\n",CKSUM_ATTRIBUTE);
CKSUM_ATTRIBUTE already contains the output of calling cksum ARGV1,
that I have already confirmed, and RETURN_CODE_2 matches up until the
next line strange character situation.
I am lost for ideas and appreciate any guidance or idears. Thank you!