D
Darklight
I am using suse 9.3 pro
Why is it when i run this program in the konsole
i get the out put:
1st string: To be or not to be?
2nd string: To bTo be or not to be?
which it should not be
but when i run the same program in the ddd debugger i get
1st string: to be or not to be:
2nd string: to be
which it should be according to the book: c programming in easy steps
the program is below:
#include<stdio.h>
#include<string.h> /* make strncpy available */
int main(void)
{
char string1[] = "To be or not to be?";
char string2[6];
/* copy first 5 characters in string1 to string2 */
strncpy(string2, string1, 5);
printf("1st string: %s\n", string1);
printf("2nd string: %s\n", string2);
return 0;
}
Why is it when i run this program in the konsole
i get the out put:
1st string: To be or not to be?
2nd string: To bTo be or not to be?
which it should not be
but when i run the same program in the ddd debugger i get
1st string: to be or not to be:
2nd string: to be
which it should be according to the book: c programming in easy steps
the program is below:
#include<stdio.h>
#include<string.h> /* make strncpy available */
int main(void)
{
char string1[] = "To be or not to be?";
char string2[6];
/* copy first 5 characters in string1 to string2 */
strncpy(string2, string1, 5);
printf("1st string: %s\n", string1);
printf("2nd string: %s\n", string2);
return 0;
}