Hi
Im following a video explaning C but now im stumbling across an example that wont compile.
The dude from VTC makes it very clear that its the C90 standart im looking at but it dosent seem so ...
This is the example:
And this is the compile error:
Anyone got any clues ... i have been trying different stuff with gets and i can get that to work but "cc" keeps telling me that its not a secure way due to the fact that it can overflow.
/lbl
Im following a video explaning C but now im stumbling across an example that wont compile.
The dude from VTC makes it very clear that its the C90 standart im looking at but it dosent seem so ...
This is the example:
Code:
#include <stdio.h>
#include <stdlib.h>
struct Date {
int Month;
int Day;
int Year;
};
struct Date AddDecade(struct Date);
int main(int argc, char *argv[])
{
struct Date Bday;
char buffer[50];
printf("what month where you born? ");
Bday.Month = atoi(gets_s(buffer, 50));
printf("What day where you born? ");
Bday.Day = atoi(gets_s(buffer, 50));
printf("What year where you born? ");
Bday.Year = atoi(gets_s(buffer, 50));
printf("You where born on %d, %d, %d.\n", Bday.Month, Bday.Day, Bday.Year);
Bday = AddDecade(Bday);
printf("You will be 10 years older on %d, %d, %d\n", Bday.Month, Bday.Day, Bday.Year);
}
struct Date AddDecade(struct Date Target)
{
Target.Year += 10;
return Target;
}
And this is the compile error:
Code:
[lbl@atom0 ~/c-test-code]$ cc struct2.c
struct2.c: In function 'main':
struct2.c:19: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast
struct2.c:22: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast
struct2.c:25: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast
/var/tmp//ccsiuwYr.o(.text+0x2d): In function `main':
: undefined reference to `gets_s'
/var/tmp//ccsiuwYr.o(.text+0x5c): In function `main':
: undefined reference to `gets_s'
/var/tmp//ccsiuwYr.o(.text+0x8b): In function `main':
: undefined reference to `gets_s'
[lbl@atom0 ~/c-test-code]$
Anyone got any clues ... i have been trying different stuff with gets and i can get that to work but "cc" keeps telling me that its not a secure way due to the fact that it can overflow.
/lbl