
26.04.2009, 18:33
|
|
Познающий
Регистрация: 17.01.2007
Сообщений: 94
С нами:
10165774
Репутация:
65
|
|
Может я что то не так делаю, вот мой код может кто нить подскажет что не так?
PHP код:
#include <stdio.h>
#include <time.h>
struct tm intime; // создаю структуру типа tm которая описана в time.h
int* funct(struct tm *p); // обьявление функции
int* funct(struct tm *p) // описание
{
int temp[7]; // создаем массив который вернется
temp[0] = p.tm_sec; // присваиваем элементам массива, значения структуры
temp[1] = p.tm_min; // ..
temp[2] = p.tm_hour;
temp[3] = p.tm_mday;
temp[4] = p.tm_mon;
temp[5] = p.tm_year;
temp[6] = '\0'; // закрываем массив
return temp; // возвращаем массив
}
int main (void)
{
int *temp2; // создаем указатель на массив который получим из функции
{
intime.tm_sec=10; // присваиваем значения элементам нашей входной структуры
intime.tm_min=19;
intime.tm_hour=20;
intime.tm_mday=14;
intime.tm_mon=5;
intime.tm_year=109;
}
temp2 = funct(&intime); // пытаемся отправить структуру в функцию и ничего не выходит ((
return 0;
}
Compiling source file(s)...
gps.cpp
gps.cpp: In function `int* funct(tm*)':
gps.cpp:9: error: `tm_sec' has not been declared // здесь непонимаю почему ругается, ведь мы обьявили структуру в файле <time.h>
gps.cpp:9: error: request for member of non-aggregate type before ';' token
gps.cpp:10: error: `tm_min' has not been declared
gps.cpp:10: error: request for member of non-aggregate type before ';' token
gps.cpp:11: error: `tm_hour' has not been declared
gps.cpp:8: warning: address of local variable `temp' returned // здесь вроде ругается что возвращаем локальную а не глобальную переменную
|
|
|