sourcecode
چهارشنبه 05 شهریور 1393, 20:04 عصر
در محیط کنسول خبری از دکمه و منو نیست. پس برای اینکه اطلاعات کاربر را گرفته و دستور مورد نظر کاربر را اجرا کنیم , از اینترفیس فرمانی استفاده می کنیم که در برنامه ساده زیر طریقه نوشتن کد به صورت اینترفیس فرمانی آمده شده است .
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i,j;
char str1[10];
char c='y';
cout<<"Enter String : ";
cin>>str1;
for(i=0;i<=strlen(str1);i++)
str1[i]=( tolower(str1[i]) );
for( ;(c=='y' || c=='Y'); )
{
system("cls");
if( !(str1 != "sum") || !(str1 != "division") ) break;
cout<<endl;
if( !strcmp(str1,"quit") ) break;
cout<<"Enter i & j : ";
cin>>i>>j;
system("cls");
cout<<"value String is : "<<str1<<endl;
cout<<"Value i is : "<<i<<endl;
cout<<"Value j is : "<<j<<endl;
if( !strcmp(str1,"sum") )
cout<<"\nsum : "<<i+j;
else if( !strcmp(str1,"division") )
cout<<"division : "<<i/j;
else
cout<<"Unknown Command.";
cout<<"\n\nDo you Want continue . . . ";
cin>>c;
}
cout<<"\nBy By . . ." ;
cin.get();
cin.get();
return 0;
}
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i,j;
char str1[10];
char c='y';
cout<<"Enter String : ";
cin>>str1;
for(i=0;i<=strlen(str1);i++)
str1[i]=( tolower(str1[i]) );
for( ;(c=='y' || c=='Y'); )
{
system("cls");
if( !(str1 != "sum") || !(str1 != "division") ) break;
cout<<endl;
if( !strcmp(str1,"quit") ) break;
cout<<"Enter i & j : ";
cin>>i>>j;
system("cls");
cout<<"value String is : "<<str1<<endl;
cout<<"Value i is : "<<i<<endl;
cout<<"Value j is : "<<j<<endl;
if( !strcmp(str1,"sum") )
cout<<"\nsum : "<<i+j;
else if( !strcmp(str1,"division") )
cout<<"division : "<<i/j;
else
cout<<"Unknown Command.";
cout<<"\n\nDo you Want continue . . . ";
cin>>c;
}
cout<<"\nBy By . . ." ;
cin.get();
cin.get();
return 0;
}