Click here to Skip to main content
15,904,288 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWant to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
WindowsVsLinux9-Oct-09 9:40
WindowsVsLinux9-Oct-09 9:40 
AnswerRe: Want to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
includeh109-Oct-09 18:12
includeh109-Oct-09 18:12 
GeneralRe: Want to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
WindowsVsLinux9-Oct-09 19:55
WindowsVsLinux9-Oct-09 19:55 
GeneralRe: Want to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
Richard MacCutchan9-Oct-09 23:04
mveRichard MacCutchan9-Oct-09 23:04 
GeneralRe: Want to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
WindowsVsLinux9-Oct-09 23:49
WindowsVsLinux9-Oct-09 23:49 
GeneralRe: Want to know about storing the output of FindFirstFile() and FindNextFile() in an array Pin
Richard MacCutchan10-Oct-09 0:15
mveRichard MacCutchan10-Oct-09 0:15 
GeneralIs there any way to store the output of FindFirstFile() and FindNextFile() in an array Pin
WindowsVsLinux10-Oct-09 23:21
WindowsVsLinux10-Oct-09 23:21 
Questionturbo c codes.. need help Pin
Tabang9-Oct-09 7:05
Tabang9-Oct-09 7:05 
AnswerRe: turbo c codes.. need help Pin
Richard MacCutchan9-Oct-09 7:17
mveRichard MacCutchan9-Oct-09 7:17 
QuestionRe: turbo c codes.. need help Pin
David Crow9-Oct-09 7:32
David Crow9-Oct-09 7:32 
AnswerRe: turbo c codes.. need help Pin
Nemanja Trifunovic9-Oct-09 7:37
Nemanja Trifunovic9-Oct-09 7:37 
GeneralRe: turbo c codes.. need help Pin
David Crow9-Oct-09 7:45
David Crow9-Oct-09 7:45 
GeneralRe: turbo c codes.. need help Pin
CPallini9-Oct-09 8:27
mveCPallini9-Oct-09 8:27 
GeneralRe: turbo c codes.. need help Pin
Tabang9-Oct-09 19:07
Tabang9-Oct-09 19:07 
GeneralRe: turbo c codes.. need help Pin
Tabang9-Oct-09 19:04
Tabang9-Oct-09 19:04 
AnswerRe: turbo c codes.. need help Pin
Tabang9-Oct-09 12:59
Tabang9-Oct-09 12:59 
GeneralRe: turbo c codes.. need help Pin
theCPkid9-Oct-09 22:57
theCPkid9-Oct-09 22:57 
AnswerRe: turbo c codes.. need help Pin
CPallini9-Oct-09 12:18
mveCPallini9-Oct-09 12:18 
AnswerRe: turbo c codes.. need help Pin
theCPkid9-Oct-09 22:48
theCPkid9-Oct-09 22:48 
GeneralRe: turbo c codes.. need help Pin
Tabang10-Oct-09 6:13
Tabang10-Oct-09 6:13 
GeneralRe: turbo c codes.. need help Pin
Tabang10-Oct-09 6:58
Tabang10-Oct-09 6:58 
GeneralRe: turbo c codes.. need help Pin
theCPkid10-Oct-09 15:50
theCPkid10-Oct-09 15:50 
QuestionFIle handling. turbo c Pin
Tabang9-Oct-09 6:53
Tabang9-Oct-09 6:53 
QuestionRe: FIle handling. turbo c Pin
David Crow9-Oct-09 7:50
David Crow9-Oct-09 7:50 
AnswerRe: FIle handling. turbo c Pin
CPallini9-Oct-09 12:08
mveCPallini9-Oct-09 12:08 
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];
	/*={'I','V','X','L','C','D','M'};*/

	char c;
	int counter=0;
	fpi = fopen("input.txt","r");
	fp = fopen("output.txt","a+");
	if (!fp || !fpi) return;
	while (!feof(fp))
	{
		//clrscr();
		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.

Smile | :)

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

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.