Click here to Skip to main content
15,890,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiondll access violation with Excel 32 / 64 bits Pin
Danilo Lemos 20216-Jan-23 1:30
Danilo Lemos 20216-Jan-23 1:30 
AnswerRe: dll access violation with Excel 32 / 64 bits Pin
Victor Nijegorodov6-Jan-23 5:49
Victor Nijegorodov6-Jan-23 5:49 
QuestionLinker error when adding Ole to my application, what am I missing? Pin
charlieg4-Jan-23 16:15
charlieg4-Jan-23 16:15 
AnswerRe: Linker error when adding Ole to my application, what am I missing? Pin
CPallini4-Jan-23 22:14
mveCPallini4-Jan-23 22:14 
GeneralRe: Linker error when adding Ole to my application, what am I missing? Pin
charlieg6-Jan-23 5:07
charlieg6-Jan-23 5:07 
QuestionRe: Linker error when adding Ole to my application, what am I missing? Pin
Randor 5-Jan-23 16:41
professional Randor 5-Jan-23 16:41 
AnswerRe: Linker error when adding Ole to my application, what am I missing? Pin
charlieg6-Jan-23 10:17
charlieg6-Jan-23 10:17 
GeneralRe: Linker error when adding Ole to my application, what am I missing? Pin
Randor 6-Jan-23 10:40
professional Randor 6-Jan-23 10:40 
Questionhow to interact with access control and open the door from My c++ desktop application Pin
Zouaoui Billel31-Dec-22 4:58
Zouaoui Billel31-Dec-22 4:58 
AnswerRe: how to interact with access control and open the door from My c++ desktop application Pin
Richard MacCutchan31-Dec-22 5:11
mveRichard MacCutchan31-Dec-22 5:11 
QuestionMessage Closed Pin
27-Dec-22 9:31
Member 1496877127-Dec-22 9:31 
AnswerRe: How to link C code to which Bluetooth library ? ( Linux) Pin
k505427-Dec-22 10:30
mvek505427-Dec-22 10:30 
AnswerRe: How to link C code to which Bluetooth library ? ( Linux) Pin
Richard MacCutchan27-Dec-22 22:03
mveRichard MacCutchan27-Dec-22 22:03 
QuestionInsert a Container App Pin
Glenn Meadows 202227-Dec-22 5:07
Glenn Meadows 202227-Dec-22 5:07 
AnswerRe: Insert a Container App Pin
Richard MacCutchan27-Dec-22 22:06
mveRichard MacCutchan27-Dec-22 22:06 
SuggestionRe: Insert a Container App Pin
David Crow28-Dec-22 4:49
David Crow28-Dec-22 4:49 
QuestionHaving trouble with a function in C Pin
BuilderboiYT26-Dec-22 15:38
BuilderboiYT26-Dec-22 15:38 
<pre lang="C"></pre>In my program, I am asking the user to input a date(in just integers ie 12 31 2019 367) and the number of days they add to it. In one of my functions, this is precisely what I am doing.

The user inputs 12 31 2019 367, and the program is meant to print 1 1 2021, but instead prints 1 1 2020(a year behind)...

What I did(Sorry for a lot of code, I tried to keep it simple and clean):

int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void add_days_to_date(int *mm, int *dd, int *yy, int days_left_to_add)
{
int days_left_in_month;
while(days_left_in_month > 0)
{
days_left_in_month = days_in_month[*mm] - *dd;
// days_left_in_month = days_in_month[*mm] - *dd;
if (days_in_month[2] && is_leap_year(*yy) == true)
{
days_left_in_month++;
}
} // end while
printf("after while\n");
if(days_left_to_add > days_left_in_month)
{
days_left_to_add -= days_left_in_month;
*dd = 1;
if(*mm == 12)
{
*mm = 1;
(*yy)++;
}
else
{
(*mm)++;
}
}
else
{
*dd += days_left_to_add;
days_left_to_add = 0;
}
}
int main()
{
int mm, dd, yy, days_left_to_add;
printf("Please enter a date between the years 1800 and 10000 in the format mm dd yy and provide the number of days to add to this date:\n");
scanf("%d %d %d %d", &mm, &dd, &yy, &days_left_to_add);
// printf("\nREAD\n");
//These are pointers, so they have to be at certain location i.e. int* mm = &mm
add_days_to_date(&mm, &dd, &yy, days_left_to_add);
printf("%d %d %d\n", mm, dd, yy);
}
What I got after inputs:

Inputs: 12 31 2019 367

Output: 1 1 2020(meant to be 1 1 2021)

Thank you in advance and for your time and patience...</pre>
AnswerRe: Having trouble with a function in C Pin
Victor Nijegorodov26-Dec-22 20:12
Victor Nijegorodov26-Dec-22 20:12 
AnswerRe: Having trouble with a function in C Pin
Richard MacCutchan26-Dec-22 22:10
mveRichard MacCutchan26-Dec-22 22:10 
AnswerRe: Having trouble with a function in C Pin
Mircea Neacsu26-Dec-22 22:34
Mircea Neacsu26-Dec-22 22:34 
GeneralRe: Having trouble with a function in C Pin
Richard MacCutchan26-Dec-22 23:39
mveRichard MacCutchan26-Dec-22 23:39 
QuestionInvalid comparator for STL map Pin
ForNow25-Dec-22 18:08
ForNow25-Dec-22 18:08 
AnswerRe: Invalid comparator for STL map Pin
Daniel Pfeffer25-Dec-22 19:36
professionalDaniel Pfeffer25-Dec-22 19:36 
GeneralRe: Invalid comparator for STL map Pin
ForNow25-Dec-22 21:33
ForNow25-Dec-22 21:33 
GeneralRe: Invalid comparator for STL map Pin
ForNow26-Dec-22 5:14
ForNow26-Dec-22 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.