|
No surprise, since the latter program is a bad porting of the former one. Try
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
FILE *fp, *fpi;
int a;
char base[2];
int i,x;
char str[50];
char c;
int counter=0;
fpi = fopen("input.txt","r");
fp = fopen("output.txt","a+");
if (!fp || !fpi) return;
while (!feof(fp))
{
if(counter!=0)
{
for(i=0;str[i]!=NULL;i++)
str[i]=' ';
}
if (fscanf(fpi, "%d",&a) != 1) break;
fprintf(fp,"\n\nHindu Arabic: %d",a);
if(a<=0 || a>=4000)
{
printf("out of range");
fprintf(fp,"\t\tOut of range!!!!");
goto exit;
}
i=0;
while(a>0)
{
if(a>=1 && a<4)
{
base[0] = 'I'; base[1] = ' ' ; a = a-1;
}
else if(a>=4 && a<5)
{
base[0] = 'I'; base[1] = 'V'; a = a-4;
}
else if(a>=5 && a<9)
{
base[0] = 'V'; base[1] = ' '; a = a-5;
}
else if(a>=9 && a<10)
{
base[0] = 'I'; base[1] = 'X'; a = a-9;
}
else if(a>=10 && a<40)
{
base[0] = 'X'; base[1] = ' '; a = a-10;
}
else if(a>=40 && a<50)
{
base[0] = 'X'; base[1] = 'L'; a = a-40;
}
else if(a>=50 && a<90)
{
base[0] = 'L'; base[1] = ' '; a = a-50;
}
else if(a>=90 && a<100)
{
base[0] = 'X'; base[1] = 'C'; a = a-90;
}
else if(a>=100 && a<400)
{
base[0] = 'C'; base[1] = ' '; a = a-100;
}
else if(a>=400 && a<500)
{
base[0] = 'C'; base[1] = 'D'; a = a-400;
}
else if(a>=500 && a<900)
{
base[0] = 'D'; base[1] = ' '; a = a-500;
}
else if(a>=900 && a<1000)
{
base[0] = 'C'; base[1] = 'M'; a = a-900;
}
else if(a>=1000 && a<4000)
{
base[0] = 'M'; base[1] = ' '; a = a-1000;
}
else
{
base[0] = ' '; base[1] = ' ';
}
str[i]=base[0];
str[i+1]=base[1];
i+=2;
}
str[i]='\0';
fprintf(fp,"\t\tRoman Numeral:");
for(i=0;str[i]!='\0';i++)
{
if ( str[i] != ' ')
{
fprintf(fp,"%c",str[i]);
}
}
exit:
counter++;
}
fclose(fp);
fclose(fpi);
}
BTW: In both programs you missed to zero-terminate the string str .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, October 9, 2009 6:16 PM
|
|
|
|
|
thanks so much for that, but the c would become assigned and not used... what should be done?
|
|
|
|
|
thanks so much for that ops it worked i erased the do statement...sorry about that.....Thanks..... what should i do i the input of that one will be a set off numbers and separater by comma?... and the average of that set number will be that one that is converted into Roman numerals?
pls help
|
|
|
|
|
Hi,
I have a class that handle .html files but the file that came to me is a .doc, so, i whould like to convert it to .html
There´s a .dll or .exe or classes for compiling ?
Tanks for your help.
|
|
|
|
|
How about Google[^]? The first hit[^] seems promissing already.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
You can use Word Automation to open the .doc file and save it as a .html file. After importing Word's type library, it's about 5 lines of code.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
I am new in MFC.
I am struggling with one of my system's modules which is I need to edit filed's value in the data source depending on some variables.
My problem is I stuck with Recordset type because I making the editting via SQL statment and the following which are I done so far:
CDatabase DBDecaying;
CString SqlRulesDecaying;
CString sDriver("MICROSOFT ACCESS DRIVER (*.mdb)");
CString sDsn;
CString ssDSN("ODBC;DRIVER={%s};DSN='';DBQ=%s");
CString sFile("c:\\DB\\db.mdb");
sDsn.Format(ssDSN, sDriver, sFile);
DBDecaying.Open(NULL,false,false,sDsn);
CRecordset RecSetRulesDecaying( &DBDecaying );
int X=2,Y=3;
double NewActiLevel = 0;
SqlRulesDecaying.Format(_T("update Rules set RActiLevel=%f where CNum=%d and
RNum=%d"),NewActiLevel,X,Y);
RecSetRulesDecaying.Open(CRecordset::forwardOnly,SqlRulesDecaying,CRecordset::??????);
Regarding the first parameter I tried snapshot,dynaset and dynamic instead of forwardonly. nothing happens.
So what I should put insted of ???? I tried (Update,Can Update,..) but I had syntax errors.
So please any help will be appreciated.
Best regards.
|
|
|
|
|
moh.hijjawi wrote: Regarding the first parameter I tried snapshot,dynaset and dynamic instead of forwardonly. nothing happens.
Since CRecordset::forwardOnly is a read-only recordset, that would be the one to not choose. Any of the others should work.
moh.hijjawi wrote: So what I should put insted of ????
CRecordset::none should be sufficient.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
First of all thank you.
I did like you mentioned but i have an error which is "Attempt to open a table failed- there is no columns to retrieve were specified" and I sure that the sql it is OK;
please any help
|
|
|
|
|
Have you tried:
CString sDriver("MICROSOFT ACCESS DRIVER (*.mdb)");
CString ssDSN("ODBC;DRIVER={%s};DSN='';DBQ=%s");
CString sFile("c:\\DB\\db.mdb");
CString sDsn;
sDsn.Format(ssDSN, sDriver, sFile);
int X=2,Y=3;
double NewActiLevel = 0;
CString SqlRulesDecaying;
SqlRulesDecaying.Format(_T("update Rules set RActiLevel=%f where CNum=%d and RNum=%d"),NewActiLevel,X,Y);
CDatabase DBDecaying;
DBDecaying.Open(NULL,false,false,sDsn);
DBDecaying.ExecuteSQL(SqlRulesDecaying);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Now it works fine. so there is no need for recordset statement.
Thank you very much indeed
|
|
|
|
|
Hi all,
I have a Report style list control an i want to search an item inside that list control using Find function.
My problem is i want to search that item in second column.
LVFINDINFO info;
int nIndex = 0;
info.flags = LVFI_STRING;
info.psz = FirstRun;
while ((nIndex = g_index->FindItem(&info)) != -1)
{
g_index->DeleteItem(nIndex);
}
This code searches value in first column only.
How can i do this...
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
How about:
for (int x = 0; x < g_index.ItemCount(); x++)
{
CString strText = g_index.GetItemText(x, col);
if (strText == FirstRun)
{
g_index->DeleteItem(x);
break;
}
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
The following code genarates C4389 warning.
How to remove this?
int main()
{
int a = 9;
unsigned int b = 10;
if (a == b) // C4389
return 0;
else
return 0;
};
|
|
|
|
|
use
unsigned int a = 9;
unsigned int b = 10;
or
int a = 9;
int b = 10;
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
#pragma warning( disable : 4389 )
|
|
|
|
|
Hi
i want to set BG color for DoModal Dialogs .
can any one suggest me...
i.e i have 2 dialogs , say dg1,dg2.
when i click a button in dg1, dg2 dialog appears.i need to set the bg for dg2...
Thanks in advance
Regards
Gany
|
|
|
|
|
Hope this helps.
[EDIT]
Here is another sample how to change MFC common dialog BG color.
Life is a stage and we are all actors!
modified on Friday, October 9, 2009 6:35 AM
|
|
|
|
|
Override the
HBRUSH CXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
and return a suitable colour brush which will be used for BG color of the dialog.
Anish C.V
http://www.iedetech.com
|
|
|
|
|
|
|
|
What are you trying to do? Do you want to find, given two strings, a common subtring?
Please elaborate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
Hope this question is relevant to this forum. Would like to know how to set a break point in kdbg in a .cpp file that is not in the same directory as the exe (such that I cannot see the source code in the debugger where I wish to set the breakpoint).
Thanks for any information.
|
|
|
|
|
Hello ALL,
In one of my applications running under local user account, I need to spawn a process internally from system account.I was using OpenProcessToken () and was trying to collect token of winlogon.exe running under system account and was specifying flag as TOKEN_ALL_ACCESS but this fails.
Also if I specify the FLAG as TOKEN_QUERY then I get the handle but then trying to CreateProcesswithUser resulted in Error "Access is denied". Can some body suggest me a solution through which I can spawn a new process through SYSTEM account when my process itself is running through a user account .
Regards,
Kushagra
I hate to code but I luv to develop
modified on Friday, October 9, 2009 3:29 AM
|
|
|
|