|
hmmm.....having a hard time ,huh......chillout....assuming u know the basics.....herez a skeletal prgm.....
//since they have asked for atleast six functions,herez how i have seperated em as.....
#include<iostream.h>
#include<conio.h>
void getdata(int a,int b);
void convert(int num,int roman[]);
void add_roman_numeralz(int roman1[],int roman2[],int romansum[]);
void carry_correction(int roman[]);
void display_romansum(int roman[]);
void main(void)
{
int num1,num2,sum;
int roman1[7]=NULL,roman2[7]=NULL,roman3[7]=NULL;
clrscr();
//get the data from the user.....
getdata(num1,num2);
//convert num1 into roman
convert(num1,roman1);
//convert num2 into roman
convert(num2,roman1);
//perform the roman addition and get the added value in roman3
add_roman_numeralz(roman1,roman2,roman3);
//perform the carry correction for the added roman3
carry_correction(roman3);
//display the roman3
display_romansum(roman3);
getch();
}//end of void main(void)
void getdata(int &a,int &b)
{
cout<<"Enter the first number : ";
cin>>a;
cout<<"Enter the second number : ";
cin>>b;
}//end of the function
void convert(int num,int roman[7])
{
while(num>=1000)
{
roman[6]+=1;
num-=1000;
}
while(num>=500)
{
roman[5]+=1;
num-=500;
}
while(num>=100)
{
roman[4]+=1;
num-=100;
}
while(num>=50)
{
roman[3]+=1;
num-=50;
}
while(num>=10)
{
roman[2]+=1;
num-=10;
}
while(num>=5)
{
roman[1]+=1;
num-=5;
}
while(num>=1)
{
roman[0]+=1;
num-=1;
}
}//end of the function
void add_roman_numeralz(int roman1[7],int roman2[7],int romansum[7])
{
for(i=0;i<7;i++)
romansum[i]=roman1[i]+roman2[i];
}//end of function
void carry_correction(int roman[7]);
{
while(roman[0]>=5)//safer to give while,u can give if as well
{
roman[1]+=1;
roman[0]-=5;
}
while(roman[1]>=10)//safer to give while,u can give if as well
{
roman[2]+=1;
roman[1]-=10;
}
while(roman[2]>=50)//safer to give while,u can give if as well
{
roman[3]+=1;
roman[2]-=50;
}
while(roman[3]>=100)//safer to give while,u can give if as well
{
roman[4]+=1;
roman[3]-=100;
}
while(roman[4]>=500)//safer to give while,u can give if as well
{
roman[5]+=1;
roman[4]-=500;
}
while(roman[5]>=1000)//safer to give while,u can give if as well
{
roman[6]+=1;
roman[5]-=1000;
}
}//end of function
void display_romansum(int roman[]);
{
for(i=0;i<7;i++)
cout<<roman[i]<<"\n";
}//end of function
hope that helpz.....(never tried it out.....)
cheerz
|
|
|
|
|
Thanks for your help guys!
rateep, i have send an email to your yahoo.com inbox. Can u reply me soon? Thanks!
|
|
|
|
|
Hi,
I was wondering if someone with more knowledge of the windows XP and drivers can help me debug a problem. I use a CMU 1394 Camera driver that comes with an API to connect and capture some images from a camera. The problem is that after a few times of starting and stopping the program the program no longer runs with an error that there are not enough 1394 bus resources. So something doesn't get released, I need to restart the computer. I call the API functions from threads, but I check and I destroy all the threads after a certain time using:
if ( (::WaitForSingleObject( pThread1->m_hThread , 12000 )) == WAIT_TIMEOUT )
::TerminateThread( pThread1->m_hThread , 0 ) ;
Now the problem is that looking at my code I destroy all my threads. Using a program such as Sysinternals Process Explorer or the Task Manager all the threads and the process from my program get destroyed. I don't see what's holding the resources so that I can end it.
Any suggestions on programs or things to try?
Thanks.
|
|
|
|
|
terminating the thread might not be enough.
have you looked at where the 1394 (firewire ) bus is beeing used ? there must be a way to release the bus after that.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I can only guess at where the bus is being used by the library. I don't have the source code and if I didn't I wouldn't understand it for a while. Also I call all the functions that are supposed to stop your use of the driver...
Looks like I'm stuck.
|
|
|
|
|
Hi,
i've created my own tree control from a static window. The background is
transparent and all the items have a transparent background when not
selected. When and item is selected, I use a brush to fill the background:
::FillRect( hdc, &rBkgr, m_hBackBrush );
When an item is losing focus (being unselected), I do this:
::FillRect( hdc, &rItem, m_hNullBrush ); //Where m_hNullBrush is
GetStockObject( NULL_BRUSH );
The problem I have is that the item's background is not being refreshed. It
should be transparent so that the static window background should be
visible.
If I hide the window, the static control will refresh itself correctly. I've tried to use InvalidateRect() and UpdateWindow() but it does not work!
What can I do?
Thanks!
|
|
|
|
|
Never use UpdateWindow it can cause huge problems.
Use say:
HBRUSH CColorStatic::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hbr;
pDC->SetTextColor(m_crFg);
pDC->SetBkColor(m_crBg);
hbr = *m_pBrush;
return hbr;
}
Change the m_cr?? values and let the frame handle it.
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
I am writing a program in c++ in which as the user types letters
in an ms dos console the letters are changed to whatever i want them to be.
For example if the person types "How are you" as they type i want to change the letters to "Whats up" instead...Do i have to change the cin code itself to not print to the screen or what?
|
|
|
|
|
I wonder if getchar() or _getche() would be better suited for this.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
use the command "getch()"(conio.h) to input characters from the keyboard(this function goes not display them on the screen),then when u take in a character using getch() command,write a code in such a way that it simultaneously displays a charcter that u want to be displayed using a character display command(use any display command)
hope that helpz.....
happy programmin.....
cheerz.....
|
|
|
|
|
by the way.....u have to change the cin code coz the the cin command is basically used to get it a string of data and it keeps on taking in the data till and enter key is pressed(not to mention,if there r spaces between the string that u have written then only till where the space is encountered is passed to the variable).....moreover the cin command "echoes" the characters on the screen.....
use the getch() command.....it takes in only one character.....so if u want to keep getting in data like cin command then u have to make a loop in such a way that it keeps on accepting characters till and enter character is encountered.....why i say to use getch() is becoz it doesnt display the characters on the screen and therefore u can use an another command along with this (in the loop) to keep displaying the characters(cout<
|
|
|
|
|
Hello,
I have made a Visual C++ 6 application that runs under Windows 2000 Professional.
The fact is that this app runs smooth, but after two days of continuous working it appears the typical message: "not enough virtual memory..." (or something like that (I can read it in spanish)).
I cannot stop the computer each day because the software is part of a machine that must work 24 hours per day.
Any idea?
Thank you in advance.
PS:
I've tried rational purify plus, but it shows me some leakages that are not real leaks. It seems that it cannot go through intelligent pointers and other kind of VC++ stuff.
|
|
|
|
|
try using _CrtMemDifference() and its helper functions to determine if memory is different before and after a function call. If so, write it out to a text file, with name of function (I think you can use __function__ or something like that). maybe that will not be the best course of action, but it might get you closer. The best way I can think of would be to have a debug version running, and whenever it reports a memdifference, have the program break, so that you can see where this memory allocation is occurring at.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
This is a typical Handles consume.
Try to free handles for exmaple if you are using FindFirstFile and FindNextFile You need to call a FindClose after finish your process.
Also, search for all the functions that produce handles direct or indirect and make the release function if necesary.
Watch in the Task Manager to see the Handles consume and where they are not incremented You problem will be resolved.
|
|
|
|
|
Hello,
I’m looking for a slider that has the pointer invisible until the first time user clicks on it. Can anybody help me?
Thanks ahead.
teneff
|
|
|
|
|
If the pointer is initially invisible, how would the user know to click on it to make the pointer appear?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Well, it is just the pointer invisible, the rest of the slider is there. The user should evaluate some question, but if the pointer of the slider is showing anywhere in the slider range the user has an initial value to hold on witch is not so desired. I can send you a GUI jpg via email to give you a better view of the problem.
teneff
|
|
|
|
|
teneff wrote:
Well, it is just the pointer invisible, the rest of the slider is there.
I understand that part. But a slider control without the "pointer" no longer looks like a slider control. Correct? I'm curious how the user would know to click the slider control in order to get the "pointer" to display. That just seems counter-intuitive.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Need help please. Sorry for long and tedious introduction.
In Win32 API the OpenFileDialog runs by initializing the OPENFILENAME struct. (quote msdn) a buffer provided in the ofn.lpstrFile member holds all the file info including path. The ofn.lpstrFileTitle holds the name of the file and ofn.MaxFile member points to the offset in the string contained in lpstrFile where the filename is located.
If ofn.dwFlags is provided with the OFN_ALLOWMULTISELECT flag ,one is able to select multiple files at a time ,which all are contained-separated by '\0'- in the lpstrFile buffer. So this would look someting like
"C:\programs\myapp\0file1.txt\0file2.txt\0"
msdn states that if the multiselect-flag is NOT set,than the system takes the path info from the lpstrFile buffer. However,this seems not to be the case when the multiselect flag is set. It seems that in multi-mode directory information is no longer preserved. Sadly msdn doesn't touch this subject, does anyone know if ,and how the path info in case of multiselect is stored?
For processing more selected files, I read them out of the buffer one at a time and strcat them to the path,yielding a usable file-identifier. Problem however is that if I select files from directories that are further from the root,and with many characters in their name, these files seem to be invalid as the system doesn't process them any more.
As this smells of a buffer undersize,I tried enlarging sizes of various buffers and intermediate var's but however, with no success up to now. Maybe someone has a tip?
I.m currently ona Win2k system
thanx in advance
|
|
|
|
|
henry128 wrote:
However,this seems not to be the case when the multiselect flag is set. It seems that in multi-mode directory information is no longer preserved. Sadly msdn doesn't touch this subject, does anyone know if ,and how the path info in case of multiselect is stored?
This works for me:
OPENFILENAME ofn = {0};
char szBuffer[4096] = {0},
szPath[MAX_PATH];
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
ofn.lpstrFile = szBuffer;
ofn.nMaxFile = sizeof(szBuffer);
ofn.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER;
if (GetOpenFileName(&ofn) != FALSE)
{
lstrcpy(szPath, ofn.lpstrFile);
ofn.lpstrFile += ofn.nFileOffset;
while (*(ofn.lpstrFile) != '\0')
{
TRACE("%s\\%s\n", szPath, ofn.lpstrFile);
ofn.lpstrFile += lstrlen(ofn.lpstrFile) + 1;
}
} However, without a code snippet showing what you have (tried), it's hard to suggest a solution.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to get the Security Options which are found in MMC snap in Group Policy.
What API function can i use.
Yuvaraj N
|
|
|
|
|
who has sourcecode-project SMTP in Mail? please give me
long
|
|
|
|
|
Try here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
P.J. Naughter has sample project here and at www.naughter.com
"Naked we come and bruised we go."
- James Douglas Morrison
Best Wishes,
ez_way
|
|
|
|
|
I make a html view project. In the project, i want to edit it as WYCIWYG method and the problem comes when i want to save the file(html files) that i've edited.
Any algorithm or a simple source code that i can learn?
Anyway thanks.
Efendy_ma
|
|
|
|