im having trouble and cant find whats wrong... plz help

#include "strlib.h"
#include "simpio.h"
#include "genlib.h"
#include "string.h"
int main()
{
	int i, high;
	string answer;

	printf("Think of a number in the range of 1-");
	high = GetInteger();
	printf("and I'll guess it:\nPlease use Y and N.\n");
	answer = "No";

	printf("Is the number %d ",high/2);
	answer = GetLine();

	if(StringCompare(answer, "N") == 0)
	{
		printf("\nIs the number lower than %d? ",high/2);
		answer = GetLine();
		if(StringCompare(answer, "Y") == 0)
		{
			for(i=(high/2)/2; i>1; i=i/2)
			{
				printf("\nIs the number %d?\n", i);
				answer = GetLine();

				if(StringCompare(answer, "N") == 0)
				{
					printf("\nIs the number lower than %d?\n", i);
					answer = GetLine();
				}
				else
				{
					i=1;
				}
				if(StringCompare(answer, "N") == 0)
				{
					for(i=i+1; i<i*2; i++)
					{
					printf("\nIs the number %d?\n", i);
					answer = GetLine();
					if(StringCompare(answer, "Y") == 0)
					{
						i=500;
					}
					else;
					}
				}
				else;
			}
		}

		else if(StringCompare(answer, "N") == 0)
		{
			for(i=(high/2)+high; i<high; i=(i/2)+i)
			{
				printf("\nIs the number %d?\n", i);
				answer = GetLine();

				if(StringCompare(answer, "N") == 0)
				{
					printf("\nIs the number higher than %d?\n", i);
					answer = GetLine();
				}
				else
				{
					i=1;
				}
				if(StringCompare(answer, "N") == 0)
				{
					for(i=i-1; i>i/2; i--)
					{
					printf("\nIs the number %d?\n", i);
					answer = GetLine();
					if(StringCompare(answer, "Y") == 0)
					{
						i=1;
					}
					else;
					}
				}
				else;
			}
		}
	}
	else;
	
	printf("I have succeeded in guessing your number!\n");
	system("pause");
}

Recommended Answers

All 3 Replies

You can't use string in C. Also, we can't run the program since you haven't provided the GetLine and GetInteger and StringCompare functions.

>im having trouble [...]
Can you explain what's the trouble you're having?
What's the program doing that it isn't intended to do?

commented: Well said, I was about to ask that in my post! +2

It looks like that he might have his own SDL and API by the looks of it.

@OP - What does this code do?

ssharish

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.