Ok, I've decided, programming is not for me, but I need to get this assignment finished so I'm putting it to you guys. Simple(!?) setup. The user enters a string of text in the following format John Doe*123 Baker Street*SomeCity*RG12 2AP. Now, the idea is that once the code is entered, the * will break the string down onto seperate lines. I managed to design the program to stop at the first * but now I'm stuck as to how to get it to read in the next part. My code is attached to give you some idea.
Thanks for any suggestions.
{
AnsiString Line;
int Index;
Line = ReadStringPr("Enter a non-empty line of text: "
//insist on a non-empty line
while (Line == ""
Line = ReadStringPr("Please enter a non-empty line: "
Index = 1;
while ((Index <= Length(Line)) && (Line[Index] == '*'))
Index = Index + 1;
if (Index <= Length(Line))
while ((Index <= Length(Line)) && (Line[Index] != '*'))
{
WriteChar(Line[Index]);
Index = Index + 1;
}
else WriteStringCr("You have entered a line without input."
getchar();
return 0;
Thanks for any suggestions.
{
AnsiString Line;
int Index;
Line = ReadStringPr("Enter a non-empty line of text: "
//insist on a non-empty line
while (Line == ""
Line = ReadStringPr("Please enter a non-empty line: "
Index = 1;
while ((Index <= Length(Line)) && (Line[Index] == '*'))
Index = Index + 1;
if (Index <= Length(Line))
while ((Index <= Length(Line)) && (Line[Index] != '*'))
{
WriteChar(Line[Index]);
Index = Index + 1;
}
else WriteStringCr("You have entered a line without input."
getchar();
return 0;