Well hallo comrades, just been having problems with character strings. Wrote a program that requires typing in of information yet it wasn't possible to represent the character strings in a comfortable manner for whoever is to use the program. Also is there a possible way to make the inputing of a password be in a format not seen by another during input e.g. ******* characters during input. Still polishin on proceedural programming C++. Sent a program with its executable part as an attachment. Just a simple one, any opinions on how to make a more realistic and useful program? Phone number to begin the program is 720797278. Gud day!

Attachments
#include<iostream.h>
#include<fstream.h>
#include<string.h>
main()
{
	int a;long int g;int ct,fav,fas,fam;char famo[200],favdi[200];int jtt,ctt,mm,dd;
	cout<<"****************************************************************************"<<endl;
	cout<<"****************************************************************************"<<endl;
	cout<<"\n"<<endl;
	cout<<"THE SELF EVALUATION PROGRAM"<<endl;
	cout<<"\n"<<endl;
	cout<<"Version 2004.  A Trademark of CWWA Creations"<<endl;
	cout<<"\n"<<endl;
	cout<<"****************************************************************************"<<endl;
	cout<<"****************************************************************************"<<endl;
	fstream f;
	f.open("A:FORM.DOC",ios::app);
	f<<"****************************************************************************"<<endl;
	f<<"****************************************************************************"<<endl;
	f<<"THE SELF EVALUATION PROGRAM"<<endl;
	f<<"Version 2004.  A Trademark of CWWA Creations"<<endl;
	f<<"****************************************************************************"<<endl;
	f<<"****************************************************************************"<<endl;
	cout<<"\n"<<endl;
	cout<<"THE OPTIONS ARE ANSWERED IN NUMERICALS eg 1 [meaning Yes] & 2 [meaning No]"<<endl;
	cout<<"\n"<<endl;
	cout<<"****************************************************************************"<<endl;                                                                                                                                                                                                                                                                                                                                                                                                                                                           /*
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            */g=720797278;
	do{
	cout<<"Please enter your MOBILE Number:> +254";cin>>g;
	cout<<"\a\a\a\a";cout<<"\n"<<endl;
	}
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           while(g!=720797278);
	cout<<"\a\aHow are you doing today? \n\n [1]Sad.\n [2]Happy.\n [3]Just there(Normal).\n [4]Bored.\n\nPlease Enter one Option:>";cin>>a;
	if(a==1){
		f<<"MOOD: Sad"<<endl;
	}
		if(a==2){
			f<<"MOOD: Happy"<<endl;
		}
			if(a==3){
				f<<"MOOD: Just there(Normal)"<<endl;
			}
				if(a==4){
					f<<"MOOD: Bored"<<endl;
				}
				fstream c;
				c.open("A:\\CWWA PRIVATE\\EVALUATION.DOC",ios::app);
				c<<"****************************************************************************"<<endl;
	c<<"****************************************************************************"<<endl;
	c<<"THE SELF EVALUATION PROGRAM"<<endl;
	c<<"Version I (2004).  A Trademark of CWWA Creations"<<endl;
	c<<"****************************************************************************"<<endl;
	c<<"****************************************************************************"<<endl;
	if(a==1){
		c<<"MOOD: Sad"<<endl;
	}
		if(a==2){
			c<<"MOOD: Happy"<<endl;
		}
			if(a==3){
				c<<"MOOD: Just there(Normal)"<<endl;
			}
				if(a==4){
					c<<"MOOD: Bored"<<endl;
				}
				for(ct=1;ct<=4;ct++){
					cout<<"\n"<<endl;
	cout<<"..............................................................................."<<endl;
	cout<<"What are your favourite:>\n\n [1] Sports.\n [2] Music.\n [3] Movies.\n [4] Dish.\n\nEnter one number at a time.\n(Avoid repeating one option twice) :>";cin>>fav;
	cout<<"..............................................................................."<<endl;
	cout<<"\n"<<endl;
	if(fav==1){
		cout<<"\n"<<endl;	
		cout<<"SPORTS: \n [1] Rugby.\n [2] Football.\n [3] Volley Ball.\n [4] Hand Ball.\n [5] Athletics.\n [6] Indoor Games.\n [7] Other.\n\n Enter one option:>";cin>>fas;cout<<endl;
			if(fas==1){
				cout<<"\n"<<endl;
				cout<<"SPORT: Rugby"<<endl;
				f<<"SPORT: Rugby"<<endl;
				c<<"SPORT: Rugby"<<endl;
			}
			if(fas==2){
				cout<<"\n"<<endl;
				cout<<"SPORT: Football"<<endl;
				f<<"SPORT: Football"<<endl;
				c<<"SPORT: Football"<<endl;
			}
			if(fas==3){
				cout<<"\n"<<endl;
				cout<<"SPORT: Volley Ball"<<endl;
				f<<"SPORT: Volley Ball"<<endl;
				c<<"SPORT: Volley Ball"<<endl;
			}
			if(fas==4){
				cout<<"\n"<<endl;
				cout<<"SPORT: Hand Ball"<<endl;
				f<<"SPORT: Hand Ball"<<endl;
				c<<"SPORT: Hand Ball"<<endl;
			}
			if(fas==5){
				cout<<"\n"<<endl;
				cout<<"SPORT: Athletics"<<endl;
				f<<"SPORT: Athletics"<<endl;
				c<<"SPORT: Athletics"<<endl;
			}
			if(fas==6){
				cout<<"\n"<<endl;
				cout<<"SPORT: Indoor Games"<<endl;
				f<<"SPORT: Indoor Games"<<endl;
				c<<"SPORT: Indoor Games"<<endl;
			}
			if(fas==7){
				cout<<"\n"<<endl;
				cout<<"SPORT: Other"<<endl;
				f<<"SPORT: Other"<<endl;
				c<<"SPORT: Other"<<endl;
			}
	}
	if(fav==2){
		cout<<"MUSIC:\n\n [1] R & B.\n [2] Regea.\n [3] Jam.\n [4] Gospel.\n [5] Local(Zilizopendwa).\n [6] Other.\n\nEnter one Option :>";cin>>fam;
			if(fam==1){
				cout<<"\n"<<endl;
				cout<<"MUSIC: R & B"<<endl;
				f<<"MUSIC: R & B"<<endl;
				c<<"MUSIC: R & B"<<endl;
			}
			if(fam==2){
				cout<<"\n"<<endl;
				cout<<"MUSIC: Regea"<<endl;
				f<<"MUSIC: Regea"<<endl;
				c<<"MUSIC: Regea"<<endl;
			}
			if(fam==3){
				cout<<"\n"<<endl;
				cout<<"MUSIC: Jam"<<endl;
				f<<"MUSIC: Jam"<<endl;
				c<<"MUSIC: Jam"<<endl;
			}
			if(fam==4){
				cout<<"\n"<<endl;
				cout<<"MUSIC: Gospel"<<endl;
				f<<"MUSIC: Gospel"<<endl;
				c<<"MUSIC: Gospel"<<endl;
			}
			if(fam==5){
				cout<<"\n"<<endl;
				cout<<"MUSIC: Local(Zilizopendwa)"<<endl;
				f<<"MUSIC: Local(Zilizopendwa)"<<endl;
				c<<"MUSIC: Local(Zilizopendwa)"<<endl;
			}
			if(fam==6){
				cout<<"\n"<<endl;
				cout<<"MUSIC: Other"<<endl;
				f<<"MUSIC: Other"<<endl;
				c<<"MUSIC: Other"<<endl;
			}
	}
	if(fav==3){
		cout<<"Enter number of Movies:>";cin>>mm;cout<<endl;
		cout<<"PLEASE SEPERATE WITH UNDERSCORE e.g. Men_In_Black"<<endl;
		for(ctt=1,jtt=1;ctt<=mm;jtt++,ctt++){
		cout<<"\n"<<endl;
		cout<<"Enter Your Favourite Movie:> ["<<jtt<<"]:>";cin>>famo;
		cout<<"\n"<<endl;
		cout<<"MOVIE: ["<<jtt<<"] "<<famo<<endl;
		f<<"MOVIE: ["<<jtt<<"] "<<famo<<endl;
		c<<"MOVIE: ["<<jtt<<"] "<<famo<<endl;
		}
	}
	if(fav==4){
		cout<<"Enter number of Dishes:>";cin>>dd;
		cout<<"PLEASE SEPERATE WITH UNDERSCORE e.g. Ugali_Mboga"<<endl;
			for(ctt=1,jtt=1;ctt<=dd;jtt++,ctt++){
				cout<<"\n"<<endl;
		cout<<"Enter Your Favourite Dish:> ["<<jtt<<"]:>";cin>>favdi;
		cout<<"\n"<<endl;
		cout<<"DISH: ["<<jtt<<"] "<<favdi<<endl;
		f<<"DISH: ["<<jtt<<"] "<<favdi<<endl;
		c<<"DISH: ["<<jtt<<"] "<<favdi<<endl;
			}
	}
				}
				cout<<"\a\a\aCWWA : Your Message On Line\a\a\a"<<"";
				cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<"\a.";cout<<endl;
				f<<"........................................................................"<<endl;
				f<<"Trust Not An Easy Thing You Say!\nNever Thought The Game Of Love\nThis Way You'd Play\nNever Thought These Things I Would Go Through With You\nPain Trickery And Deceit\nAll The Things You Put Me Through\nIf You Don't Wanna Say\nStill Love You Anyway\n";
				f<<"........................................................................"<<endl;
				cout<<"\n\a\a"<<endl;
				cout<<"********************************************************************************\n"<<endl;
				cout<<"\n\a\a"<<endl;
				cout<<"********************************************************************************\n"<<endl;
				cout<<"\a\a\a********************* THANK YOU FOR YOUR CO-OPERATION DEAR ! *******************\a\a\a\a\a\a\a\a\a"<<endl;
				cout<<"\a******************************************************************************\n"<<endl;
				cout<<"\n\a\a"<<endl;
				cout<<"\a******************************************************************************\n"<<endl;
				cout<<"\a******************************************************************************\n"<<endl;
				cout<<"\a******************************************************************************\n"<<endl;
				cout<<"\a***************************************************************************

Hi there I took a look at the code and yes there is a MUCH better way to get it to be user friendly. Have you thought about the use of the ANSI c++ string class (#include <cstring>)? I believe there is a code snippet showing some functions on the c/c++ snippets forum. If not try http://www.msoe.edu/eecs/ce/courseinfo/stl/string.htm as a guide. This will allow your users to input text and allows you to analyze their input! if you want options/multi-choice questions then I would stick with numbering the responses. Hope this helps :)

i had another look and realised its pretty much multiple choice so the string class may not be that simpler. however use of a switch statement would clean up the code a bit

switch (variable)
{
    case value1:
    {
        // process code if variable == value1
    }
    break;
    case value2:
    {
        // process code if variable == value 2
    }
    default:
    {
        // no matches, process code if variable did equal any of the cases
    }
    break;
};

again a google seach for the switch statement should proove useful.

This article has been dead for over six months. Start a new discussion instead.