|
-
August 29th, 2012, 03:50 AM
#1
I think this is some bug..?
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
char char1[20];
char char2[20];
void GetChar1();
void GetChar2();
int main()
{
int ch=0;
while(ch!=3)
{
cout<<"\nEnter ch: ";
cin>>ch;
if(ch==1)
GetChar1();
if(ch==2)
GetChar2();
}
getch();
return 0;
}
void GetChar1()
{
cout<<"Get Char1\n\n";
gets(char1);
cout<<"Char1: "<<char1;
getch();
}
void GetChar2()
{
cout<<"Get Char2\n\n";
gets(char2);
cout<<"Char2: "<<char2;
}
-----------------------------------------------------------------------
I am using DevC++ 4.9.9.6
I have done C++ programming before. I never encountered this type of error. What happens is that..when i enter my choice as '1', it goes to the "GetChar1()" function...but doesnt execute the gets(char1) statement in that function. Same thing happens if i enter my choice as '2'.
Please help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|