please help me fix these problem,,,,
when i'm running the program it exits emediately

main()/*Start of the function main???*/
{
	do{/*do while loop initialization*/
		print();
		scanf("%c",&choice1);
		switch(choice1){
			case 'A':
			case 'a':
				addContact();
				break;
			case 'F':
			case 'f':
				search(contacts);
				break;
			case 'v':
			case 'V':
				list();
				break;
			case 'e':
			case 'E':
				edit(contacts);
				break;
			default:
				print();
		}
	printf("");
	printf("Do you want to enter another contact?Y/N\n");/*condition question of loop*/
	scanf("%c",&choice2);
	if (choice2 == 'y' || 'Y'){
		choice2 == 'y';
	}else{
		break;
	}
	}while(choice2 ==  'Y' || choice2 == 'y');

}/*end of function main()*/

Edited 5 Years Ago by Narue: added code tags

That's the behavior coded in your snippet.
A possible solution is to use a template like this.

int main(void)
{
    /* your code here */

    getchar(); /* wait until you press a key */
    return 0;
}

I don't understand your logic here:

printf("Do you want to enter another contact?Y/N\n");/*condition question of loop*/
	scanf("%c",&choice2);
	if (choice2 == 'y' || 'Y'){
		choice2 == 'y';
	}else{
		break;
	}
	}while(choice2 ==  'Y' || choice2 == 'y');

Accept [I]choice2[/I] If [I]choice2[/I] is eith 'y' or 'Y', change it to 'y' -- this is nonsensical - it's already 'y' or 'Y' otherwise exit the DO-WHILE loop At end of DO-WHILE, test for 'y' or 'Y' -- you just set it to 'y', so you know it must be true. It can't be anything else because if it was you already broke out of the loop. And why test for 'Y'? You set it to 'y' so it can't possibly be 'Y'.

In other words remove the IF statement completely. It's redundant, unnecessary, and extraneous.

Edited 5 Years Ago by WaltP: n/a

That's the behavior coded in your snippet.
A possible solution is to use a template like this.

int main(void)
{
    /* your code here */

    getchar(); /* wait until you press a key */
    return 0;
}

tnXX alot for the help!!<3<3<3

I don't understand your logic here:

printf("Do you want to enter another contact?Y/N\n");/*condition question of loop*/
	scanf("%c",&choice2);
	if (choice2 == 'y' || 'Y'){
		choice2 == 'y';
	}else{
		break;
	}
	}while(choice2 ==  'Y' || choice2 == 'y');

Accept [I]choice2[/I] If [I]choice2[/I] is eith 'y' or 'Y', change it to 'y' -- this is nonsensical - it's already 'y' or 'Y' otherwise exit the DO-WHILE loop At end of DO-WHILE, test for 'y' or 'Y' -- you just set it to 'y', so you know it must be true. It can't be anything else because if it was you already broke out of the loop. And why test for 'Y'? You set it to 'y' so it can't possibly be 'Y'.

In other words remove the IF statement completely. It's redundant, unnecessary, and extraneous.

hehehe...tnxX for the help...yeah your right!!!my if statement was too much...i think its because i'm just a new learner...tnxxx for your help more powers..

This question has already been answered. Start a new discussion instead.