asked on
char donation[];
char donation2[];
char x;
int count, count2, i, count3;
int main() {
//donation = "$100,000";
strcpy(donation, "$100,000.00");
count = strlen(donation2);
count2 = strlen(donation)-3;
printf("the count of donation2 is %d\n", count);
printf("the count of donation is %d\n", count2);
for (i=1; i<count2; i++) {
if (isdigit(donation[i])) {
donation2[strlen(donation2)] = donation[i];
}
}
printf("donation2 is %s\n", donation2);
int count3 = atoi(donation2);
printf("converted d2 : %d\n", count3);
}
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
LoadRunner Code:
sprintf(donation, "%s", lr_eval_string("{donationAmt}"));
count = strlen(donation)-3;
count3 = 0;
for (i=1;i<count;i++) {
if (isdigit(donation[i])) {
temp2 = donation[i];
donation2[strlen(donation2)] = temp2;
}
}
donAmt2 = atoi(donation2);
if (donAmt2==rValue) {
lr_output_message("donAmt2 : %d, is equal to rvalue : %d\n", donAmt2, rValue);
}
Unix Code:
char donation[];
char donation2[];
char x;
int count, count2, i, count3;
int main() {
//donation = "$100,000";
strcpy(donation, "$100,000,000.00");
count = strlen(donation2);
count2 = strlen(donation)-3;
printf("the count of donation2 is %d\n", count);
printf("the count of donation is %d\n", count2);
for (i=1; i<count2; i++) {
if (isdigit(donation[i])) {
donation2[strlen(donation2)] = donation[i];
}
}
printf("donation2 is %s\n", donation2);
int count3 = atoi(donation2);
printf("converted d2 : %d\n", count3);
}
char donation[16]; /* <---- specify the size of the string */
char donation2[16]; /* <---- specify the size of the string */
char x;
int count, count2, i, count3;
int main() {
//donation = "$100,000";
strcpy(donation, "$100,000.00");
memset(donation2, 0, 16); /* <---- initialize the entire buffer with zero's */
count = strlen(donation2);
count2 = strlen(donation)-3;
printf("the count of donation2 is %d\n", count);
printf("the count of donation is %d\n", count2);
for (i=1; i<count2; i++) { /* <--- why are you starting at 1 ? */
if (isdigit(donation[i])) {
donation2[strlen(donation2)] = donation[i];
}
}
printf("donation2 is %s\n", donation2);
count3 = atoi(donation2); /* <---- don't re-declare count3 - you can't do that in the middle of a block anyway if you want to write valid C code */
printf("converted d2 : %d\n", count3);
return 0; /* <--- needed to make it valid C code */
}
ASKER
Software is any set of instructions that directs a computer to perform specific tasks or operations. Computer software consists of programs, libraries and related non-executable data (such as documentation). Computer software is non-tangible, contrasted with computer hardware, which is the physical component of computers. Software written in a machine language is known as "machine code". However, in practice, software is usually written in high-level programming languages than machine language. High-level languages are translated into machine language using a compiler or interpreter or a combination of the two.
TRUSTED BY