C
c_learner
goose said:Now see that it doesn't happen again
/* Thanks */
/* coded by c_learner, released under GPL v2
(http://www.gnu.org/copyleft/gpl.html) */
#include <stdlib.h>
#define NUM 5
int main(void)
{
int i = 5;
Since you have #define NUM, why not use NUM here? When the
array size changes to 7, you will then only have to change
the #define, and not hunt down all the places where you used
the magic number 5.
ah!
char a[NUM+1] = "12345";
int b[5] = {0};
while(--i > -1)
{
b = atoi(&a);
Once again, you've used the dreaded atoi(). Why not
change this as suggested above by MM?
i think i did it.
a='\0';
}
return 0;
}
/* Thanks */
/* coded by c_learner, released under GPL v2
(http://www.gnu.org/copyleft/gpl.html) */
#include <stdlib.h>
#define NUM 5
int main(void)
{
int i=NUM;
char a[NUM+1] ="12345";
int b[NUM] = {0};
while(--i > -1)
{
b = atoi(&a);
a='\0';
}
return 0;
}