C/Visual C - Pasar código C a C++

 
Vista:
sin imagen de perfil

Pasar código C a C++

Publicado por Rodrigo (1 intervención) el 16/04/2017 23:03:41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
void main()
{
    char* date1 = "9\\12\\2012";
    char* date2 = "6\\11\\2013";
 
    int day1,month1,year1;
    int day2,month2,year2;
 
    sscanf(date1,"%d\\%d\\%d",&day1,&month1,&year1); //reads the numbers
    sscanf(date2,"%d\\%d\\%d",&day2,&month2,&year2); //from the string
 
    if (year1<year2 || month1<month2 || day1<day2) //compares 2 dates
    {
        printf("date1 < date2\n");
    }
    else
    {
        printf("date1 >= date2\n");
    }
 
    char newdate[15];
 
    sprintf(newdate,"%d\\%d\\%d",13,2,1998); //make a date string from numbers
    printf("%s\n",newdate);
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder