Witam, mam problem, który objaśnię niewielkim kodem:
test1.c:
#include <stdio.h>
#include "test2.h"
char bufor[100];
int main (int argc, char **argv)
{
bufor[0] = 'B';
make_data();
printf("%s\r\n", bufor);
return 0;
}
test2.c
#include <stdio.h>
#include "test2.h"
char bufor[11];
void make_data(void)
{
int i;
for(i = 0; i < sizeof(bufor)-1; i++)
{
bufor[i] = 'A';
}
bufor[i] = 0x00;
}
test2.h:
void make_data(void);
teraz kompilacja i wykonanie:
# gcc test1.c test2.c -o test -Wall
# ./test
AAAAAAAAAA
#
WTF?