Click here to Skip to main content
15,884,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do we run an Exe File when openning the Windows? Pin
Arsalan Malik13-Dec-04 19:36
Arsalan Malik13-Dec-04 19:36 
AnswerRe: How do we run an Exe File when openning the Windows? Pin
vishalmore13-Dec-04 20:00
vishalmore13-Dec-04 20:00 
GeneralColor Palette Toolbar Pin
Tony Teveris13-Dec-04 14:17
Tony Teveris13-Dec-04 14:17 
GeneralRe: Color Palette Toolbar Pin
Sujan Christo13-Dec-04 20:58
Sujan Christo13-Dec-04 20:58 
GeneralExponents Pin
Verolix13-Dec-04 13:54
Verolix13-Dec-04 13:54 
GeneralRe: Exponents Pin
Ryan Binns13-Dec-04 16:56
Ryan Binns13-Dec-04 16:56 
GeneralRe: Exponents Pin
Yulianto.13-Dec-04 17:14
Yulianto.13-Dec-04 17:14 
GeneralParser Pin
Verolix13-Dec-04 13:51
Verolix13-Dec-04 13:51 
I wrote this string parser. It compiles without errors. But when I launch the program, it doesn't seem to quit the loop.... What's wrong?

#include <string.h>

int Parse(char *String)
{
	int Temp = 0;
	int Result = 0;
	int Length = int(strlen(String)); // The length of the string.
	bool Negative = false;
	// Main cycle. Loop through all the symbols of the string.
	for (int i = 0; i < Length; i++)
	{
		if (i = 0)
		{
			// If the first symbol of the string is "-". Make it negative.
			if (String[i] == 45)
			{
				Negative = true;
			}
		}
		else
		{
			// Make sure the input symbol is a number. Return 0 if it's not.
			if (String[i] < 48)
			{
				return 0;
			}
			else if (String[i] > 57)
			{
				return 0;
			}
			else
			{
				// For aech number, perform specific operations.
				switch (String[i])
				{
					// If it's 0.
				case 48:
					Temp = 1;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 1.
				case 49:
					Temp = 1;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 2.
				case 50:
					Temp = 2;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 3.
				case 51:
					Temp = 3;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 4.
				case 52:
					Temp = 4;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 5.
				case 53:
					Temp = 5;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 6.
				case 54:
					Temp = 6;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 7.
				case 55:
					Temp = 7;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 8.
				case 56:
					Temp = 8;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
					// If it's 9.
				case 57:
					Temp = 9;
					for (int j = 0; j < (Length - i); j++)
					{
						Temp *= 10;
					}
					Result += Temp;
					Temp = 0;
					break;
				}
			}
		}
	}
	if (Negative == true)
	{
		Result = Result - (Result * 2);
	}
	return Result;
}


Any help would be appreciated...
GeneralRe: Parser Pin
Yulianto.13-Dec-04 17:18
Yulianto.13-Dec-04 17:18 
GeneralRe: Parser Pin
*Dreamz13-Dec-04 17:50
*Dreamz13-Dec-04 17:50 
GeneralRe: Parser Pin
Antony M Kancidrowski14-Dec-04 0:57
Antony M Kancidrowski14-Dec-04 0:57 
GeneralRe: Parser Pin
toxcct14-Dec-04 4:38
toxcct14-Dec-04 4:38 
GeneralRe: Parser Pin
Verolix14-Dec-04 11:41
Verolix14-Dec-04 11:41 
GeneralRe: Parser Pin
toxcct15-Dec-04 3:00
toxcct15-Dec-04 3:00 
Generalswab function Pin
elephantstar13-Dec-04 12:46
elephantstar13-Dec-04 12:46 
GeneralPorblem Pin
engineerpilotdude13-Dec-04 12:29
engineerpilotdude13-Dec-04 12:29 
GeneralRe: Porblem Pin
Arsalan Malik13-Dec-04 19:48
Arsalan Malik13-Dec-04 19:48 
GeneralRe: Porblem Pin
namaskaaram13-Dec-04 20:34
namaskaaram13-Dec-04 20:34 
GeneralRe: Porblem Pin
Henry miller14-Dec-04 10:41
Henry miller14-Dec-04 10:41 
GeneralQuestion about static variable that define in a function Pin
nachilau13-Dec-04 10:34
nachilau13-Dec-04 10:34 
GeneralRe: Question about static variable that define in a function Pin
Joaquín M López Muñoz13-Dec-04 10:51
Joaquín M López Muñoz13-Dec-04 10:51 
GeneralRe: Question about static variable that define in a function Pin
nachilau13-Dec-04 11:11
nachilau13-Dec-04 11:11 
GeneralRe: Question about static variable that define in a function Pin
Joaquín M López Muñoz13-Dec-04 11:28
Joaquín M López Muñoz13-Dec-04 11:28 
GeneralDialog box title size Pin
act_x13-Dec-04 9:34
act_x13-Dec-04 9:34 
GeneralRe: Dialog box title size Pin
Antony M Kancidrowski13-Dec-04 9:45
Antony M Kancidrowski13-Dec-04 9:45 

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.