Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to add 7 days to a date in C

1 Answer

0 votes
#include <stdio.h>
#include <time.h>

int main(void) {
    struct tm tm = { 0 };

    tm.tm_mon = 6 - 1; // 6 (June)
    tm.tm_mday = 12;
    tm.tm_year = 2022 - 1900; // 2022
    tm.tm_isdst = -1;

    tm.tm_mday += 7; // 7 Days

    if (mktime(&tm) == -1)
        fprintf(stderr, "mktime failed");
    else	
        printf("%d/%d/%d", tm.tm_mon + 1, tm.tm_mday, tm.tm_year + 1900);

    return 0;
}




/*
run:

6/19/2022

*/

 



answered Jun 12, 2022 by avibootz

Related questions

1 answer 153 views
153 views asked May 11, 2022 by avibootz
2 answers 170 views
170 views asked Mar 28, 2022 by avibootz
1 answer 149 views
1 answer 170 views
1 answer 173 views
1 answer 160 views
1 answer 155 views
...