Jump to content
Sign in to follow this  
CyborGTX

[Resolvido] Obter dia seguinte

Recommended Posts

CyborGTX

como posso obter o dia seguinte?

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
char* textdata1,* textdata2;
time_t t;
struct tm* data;
time(&t);
data=localtime(&t);
textdata1=ctime(&t);
textdata2=asctime(data);
printf("seg: %d\n",data->tm_sec);
printf("min: %d\n",data->tm_min);
printf("horas:%d\n",data->tm_hour);
printf("dia: %d\n",data->tm_mday);
printf("mes: %d\n",data->tm_mon);
printf("ano: %d\n\n",1900+data->tm_year);
puts(textdata1);
puts(textdata2);
return 0;
}

Share this post


Link to post
Share on other sites
HappyHippyHippo
time_t t;     // <-- valor numérico

time(&t);     // <-- esperado que t terá o número de segundos que se passaram desde 00:00 hours, Jan 1, 1970 UTC

t += 60*60*24 // <-- t terá o numero de segundos da data/hora actual mais 1 dia (60 segundos * 60 minutos * 24 horas)


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
CyborGTX

tira a informação necessária da struct tm

como assim ?

(é de salientar que não sou um expert em programaçao)

Share this post


Link to post
Share on other sites
CyborGTX

resoluçao pretendida

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main()
{
 time_t t;
 struct tm* data;
 time(&t);
 data=localtime(&t);
 data->tm_mday++;
 mktime(data);

 printf("dia: %d\n",data->tm_mday);
 printf("mes: %d\n",data->tm_mon+1);
 printf("ano: %d\n\n",1900+data->tm_year);
 return 0;
}

Edited by pmg
Falta LP

Share this post


Link to post
Share on other sites
HappyHippyHippo

o objectivo seria apresentar o dia seguinte

já sabes como apresentar a informação de data, e já te disse como calcular para o dia seguinte, não estou a ver onde está a dúvida


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.