|
Hi.
Although i have some experience in VC++ but lack in fundamentals and want to learn some basics of VC++ 6.plese help me in this regard.
please forward me the links at "ubiquee@gmail.com".
thanks
|
|
|
|
|
|
Thanks for the link .but i am looking for visual C++ vesion 6.there is a difference between the version 6 and 5.(in commands and prcedures)
|
|
|
|
|
|
Hi.
Although i have some experience in VC++ but lack in fundamentals and want to learn some basics of VC++ 6.plese help me in this regard.
thanks
|
|
|
|
|
|
I have this program I have to write for school that accepts two integers. hours and minutes. I then have to output the format in 6:00 format. I'm only allowed integer division and and modulus division. I've tried everything I can think of but my output still looks like this. 6:0 Any tips?
BINARY
|
|
|
|
|
How about this?
int main(int argc, char* argv[])
{
int hours = 6;
int minutes = 7;
int seconds = 8;
printf("%d:%02d:%02d\n", hours, minutes, seconds);
return 0;
}
|
|
|
|
|
or, without using printf formatting trick, try this:
int main(int argc, char* argv[])
{
int hours = 6;
int minutes = 7;
printf("%d:%d%d\n", hours, minutes / 10, minutes % 10);
return 0;
}
|
|
|
|
|
little too advance for a student who just started learn C++ three weeks ago. Plus It has to advance the hour when the minutes go over 59. I am so stuck.
I cant even use conditional operators
Here's what I got:
#include<iostream><br />
#include<iomanip><br />
using namespace std;<br />
<br />
<br />
int main()<br />
<br />
{<br />
int hours, minutes ;<br />
<br />
<br />
cout << "Input the time as hours and minutes (e.g. 5 23 means 5:23) " ;<br />
<br />
cin >> hours >> minutes ;<br />
<br />
const int minutes_per_hour = 59;<br />
<br />
minutes = minutes + 1;<br />
<br />
<br />
<br />
<br />
cout << " The time is: " << hours<< " :"<< setfill('0')<<setw(1) << minutes << endl ;<br />
<br />
<br />
<br />
<br />
<br />
<br />
system("pause");<br />
<br />
return 0 ;<br />
<br />
}
BINARY
-- modified at 2:22 Sunday 23rd October, 2005
|
|
|
|
|
Change setw(1) to setw(2) .
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Couple more things:
- your minutes_per_hour constant should 60, not 59.
- your hours calculation, even though it is commented out, is not correct.
- after incrementing minutes, you should probably adjust its value using the mod function (% function).
Below is example code also using PJ's setw(2) change:
const int minutes_per_hour = 60;
minutes = minutes + 1;
hours = hours + (minutes / minutes_per_hour);
minutes = minutes % minutes_per_hour;
cout << " The time is: " << hours << ":"<< setfill('0') << setw(2) << minutes << endl;
In Line 1, the expression "x / y" returns the integral portion of x divided by y. When x is 60 and y is 60, this expression yields 1, which will increment the hours by 1. When x is less than y, this expression yields 0, and the hours value is unchanged.
In Line 2, the expression "x % y" returns the remainder value that you get when you divide x by y. If x is less than y, it returns just the value x. If x is 60 and y is 60, the remainder is 0, which handles the case when the minutes goes past 59 (you want it to display 00).
|
|
|
|
|
Thank you so much you people are my heroes
BINARY
|
|
|
|
|
I'll try to inform you of my problem in the best way possible. And I think the best way to do that is to show you a little code that goes with it.
<br />
CObList list;
<br />
---------------------------------------<br />
<br />
class CLineAccess : public CObject
{<br />
DECLARE_DYNAMIC( CLineAccess)<br />
<br />
---------------------------------------<br />
<br />
CLineAccess *temp;<br />
temp = (CLineAccess *)list.GetHead();
pos = list.GetHeadPosition();
<br />
dc.MoveTo(temp->GetStartX(), temp->GetStartY());<br />
dc.LineTo(temp->GetEndX(), temp->GetEndY());<br />
I then have a while loop that gets all the next lines that I am attempting to draw. The only problem is that it seems my CPaintDC dc(this); only draws the last line in the list. Does MoveTo() erase all the previous lines? I get a return of (1) on every run through of the LineTo() so I know that the lines are being drawn. Being that temp is just a local pointer used to traverse through the list I don't see any problems about reusing it. Do any of you have an idea?
|
|
|
|
|
Anonymous wrote: Does MoveTo() erase all the previous lines?
No, but your OnEraseBackground() handler clears all previously drawn lines before calling your OnPaint() handler. You'll need to repaint the entire collection of lines in OnPaint() .
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Anonymous wrote: Does MoveTo() erase all the previous lines?
MoveTo() does not erase anything.
Anonymous wrote: Being that temp is just a local pointer used to traverse through the list I don't see any problems about reusing it.
Reusing temp should not be a problem.
Anonymous wrote: I then have a while loop that gets all the next lines that I am attempting to draw.
Can you show the code for that loop? It almost seems to me that you are drawing the same line over and over again.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: Can you show the code for that loop? It almost seems to me that you are drawing the same line over and over again.
I'll do even better than that here is everything from my function:
<br />
void LoadAndDrawLines(void)<br />
{<br />
CPaintDC dc(this);<br />
CPen pen;<br />
pen.CreatePen(PS_SOLID, 1, 0x00FF0000);<br />
dc.SelectObject(&pen);<br />
CLineAccess *temp;<br />
int x = 1;<br />
POSITION pos;<br />
<br />
if(list.GetCount() > 0)<br />
{<br />
temp = (CLineAccess *)list.GetHead();<br />
pos = list.GetHeadPosition();<br />
dc.MoveTo(temp->GetStartX(), temp->GetStartY());<br />
dc.LineTo(temp->GetEndX(), temp->GetEndY());<br />
while(x < list.GetCount())<br />
{<br />
temp = (CLineAccess *)list.GetNext(pos);<br />
dc.MoveTo(temp->GetStartX(), temp->GetStartY());<br />
dc.LineTo(temp->GetEndX(), temp->GetEndY());<br />
x++;<br />
}<br />
}<br />
}<br />
LoadAndDrawLines() is called by OnPaint() btw. Also I will clean it up a bit later and move out all the pen stuff and more. Thanks for your help everyone
|
|
|
|
|
The usual pattern to enumerate over all of the elements in an MFC list is as follows:
CObList list;
POSITION position = list.GetHeadPosition();
while (position != NULL) {
element = list.GetNext(position);
} Try CObList[^] in the MSDN.
Software Zen: delete this;
|
|
|
|
|
I met a question when using vc++ .Net 2003,that is, in a project, I declare an array in .h file, but when I initialize that array in .cpp file, the compiler always show me errors. Then how to initialize an array in vc++ .Net 2003?
following is part of the .h and .cpp file.
.h file
#pragma once
#include "stdafx.h"
#include "miscgl.h"
#include "cmath.h"
#include "public.h"
class COpenGLScene
{
public:
COpenGLScene(void);
virtual ~COpenGLScene(void);
......
// backcolor of the scene.
GLclampf backColor[4];
........
};
.CPP FILE
#include <windows.h>
#include <stdio.h>
#include "StdAfx.h"
#include "openglscene.h"
COpenGLScene::COpenGLScene(void)
{
//zRot = 0;
SetCamera();
// First way:
// if using this way, the compiler will give me errors, why and how to using this way?
backColor[] = {0.4f, 0.4f, 0.4f, 1.0f};
// second way:
// if using this way to initialize it, it's OK.
backColor[0] = backColor[1] = backColor[2] = 0.4f;
backColor[3] = 1.0f;
this->isInitialized = FALSE;
}
Can I only initialize the array in the second way?
If I declare a static array, the method to initialize it is easy, but not all the array must be static one at any time.
So, how to initialize the array like the first way?
|
|
|
|
|
Using memcpy() allows you to use the first way.
GLclampf Temp[4] = {0.4f, 0.4f, 0.4f, 0.1f};
memcpy(backColor, Temp, sizeof(Temp) * sizeof(Temp[0]));
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I wouldn't use memcpy to initialize anything except arrays of integer and character types. Using it with struct 's is problematic, since the struct may have elements that shouldn't be copied directly (like pointers), or it may define an assignment operator.
Software Zen: delete this;
|
|
|
|
|
Thanks,a VC++ newer<it's me=""> has owned the world, internet is everything.
|
|
|
|
|
hello.
i need to get a html code so i can get same values out of it
but what is the best and the fastes way to do it?
|
|
|
|
|
Is there a procedure for copying folders from one place to another?
If there is such a procedure, could you tell me please which is it, and which parameters does it take?
THANK YOU!
|
|
|
|
|