my code so far......

// ProjectDevelopment.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream> // This libary allows standard input and output operations. 
#include <string> // strings are used as tempory storage - for the input to a text based file
#include <vector> // at one point in my program i expermented with vectors for data storage
using namespace std; // (or maybe std::getline;, std:: string;, std:: cout; , std:: cin; (namespace howecver is a short hand version to reduce code and possible errors. 
#include <fstream> // this allows filestreaming and allows the reading and writing of a file
#include <iomanip>
#include <cstring>
int intEnterANumber;
int intConfirmation;



ifstream in ( "Store" );

string temp;
	string strConfirmation;
	string strFirstName;
	string strSurname;
	string strMiddleName;
	string strNickName;
	string strTelephoneNo;
	string strMobileNo;
	string strHouseNo; 
	string strRoadStreet; 
	string strVillageTown; 
	string strPostcode; 

int AddFirstName(int intEnterANumber)
{
cout << "Please Enter the FirstName \n";
cin >> strFirstName;

ofstream File;

File.open("Store.txt",ios::app);

File << strFirstName;
File <<",";

File.close();



return 0;

}

int AddSurname(int intEnterANumber)
{
cout << "Please Enter the Surname \n"; 
cin >> strSurname;

ofstream File;

File.open("Store.txt",ios::app);


File << strSurname;
File <<",";

File.close();
return 0;
}
int AddMiddleName(int intEnterANumber)
{
	cout << "Please Enter the Middle Name\n"; 
	cin >> strMiddleName;

	ofstream File;

File.open("Store.txt",ios::app);

File << strMiddleName;
File <<",";

File.close();
	return 0;
}


int AddTelephoneNo(int intEnterANumber)
{
cout <<"Please Enter a Telephone Number\n"; 
cin >> strTelephoneNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strTelephoneNo;
File <<",";

File.close();
return 0;
}
int AddAddress(int intEnterANumber) // a function which is called by the switch statement. 
{
cout <<"Please Enter the House No\n"; 
cin >> strHouseNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strHouseNo;
File <<",";

File.close();


cout <<"Please Enter the road or street name\n"; // use street(ST) or (R) for road or street check validation. 
cin >> strRoadStreet; 

File.open("Store.txt",ios::app);

File << strRoadStreet;
File <<",";

File.close();


cout <<"Please Enter the Village or town name\n"; // use Village or (VI)or Town (T) for validation check on town or street 
cin >> strVillageTown;

File.open("Store.txt",ios::app);

File << strVillageTown;
File <<",";

File.close();

cout <<"Please Enter the Postcode\n"; 
cin >> strPostcode; // Check length during validation. With country as well we could have allowed selection of zipcodes etc. 

File.open("Store.txt",ios::app);

File << strPostcode;
File <<",";
File <<"\n";

File.close();

return 0;
}



int main(int argc, char *argv[]) // could just be just int main  

{

    do {
  int intEnterANumber;
  cout << "Welcome To Your Phone \n\n";
  cout << " (1) Enter a New Person's Details \n";
  cout << " (2) Enter a New Person FirstName and telephone No. \n"; 
  cout << " (3) Search Phone Book for all Names \n";
  cout << " (4) Search Phone Book by Firstname n\n";
  cout << " (5)  Exit \n\n";
  cout << "Please Select A Number From the Options Above\n ";
  
 cin >> intEnterANumber;

switch (intEnterANumber)
{
case 1: AddFirstName(intEnterANumber);
AddMiddleName(intEnterANumber);
AddSurname(intEnterANumber);
AddTelephoneNo(intEnterANumber);
AddAddress(intEnterANumber);

break;
case 2: AddFirstName(intEnterANumber);
AddTelephoneNo(intEnterANumber);
break;
//case 3:
//if(!in){
 //  cout << "Cannot open file.";
  //   exit (1);
  //}
   //char str[255];
   //while(in){
   //in.getline(str, 255);      
   //cout << str << endl;
  //}
  // in.close();
//} break;

case 4:
//bits of code not quite right    

	char*  strSearchData; 

cout << "Please enter a name for searching \n";
cin >> strSearchData,255 ;

in.open("Store.txt");

char* strDataStore;


while  ( in.getline( strDataStore, 50));
// tried to write token to seperate words in text file (creating split). 
   //using commors. 


 strcmp (strDataStore,strSearchData );
// sought of works cause error on intilzation. 
{ // Planning to use if strcmp is true do below if false do other)
	cout << strDataStore <<endl;

  in.close();
} break;


}
// case 5:

// exit(EXIT_SUCCESS)
// or
// exit(1)

	}

	while (intEnterANumber !=6 );
	
	return 0;
}

if you notice under case 4 - there is a an attempt at some rather bad search code. please help me make my file searchable. i have tried so many different ideas like linear search. but nothing is working. note strcmp and strcpy is a must. please point me in the right direction if you read this code.

many thanks to those who help me - no need to rush.

sincerly stephen.a.barratt - posted name to show it is my coding.

Is it so difficult to post using code tags?
It's nearly mentioned everywhere: in the forum announcement which you didn't read, on the background of the text box where you type in your message when making a post, above the forum announcements, in the 'Read this before posting'.

Is it so difficult to post using code tags?
It's nearly mentioned everywhere: in the forum announcement which you didn't read, on the background of the text box where you type in your message when making a post, above the forum announcements, in the 'Read this before posting'.

suppose not sorry i have been ill - and did not read everything i was supposed too. so can anyone help me with my problem please.

suppose not sorry i have been ill - and did not read everything i was supposed too. so can anyone help me with my problem please.

And selecting your code and clicking the code tag button ( # ) was asked too much?
You must be very ill then...
If you're ill then it's better to stay away from your computer and rest a bit :P

Comments
LOL, "ill", that's a new one.

Case 4 - where to start!?

You cannot just declare a char* and then use it for input - you must allocate memory to the pointer. Why not just allocate it as a char array, like char strSearchData[128]; (Choose a size you think is sufficient for any fool who attempts to abuse your program.) Then use getline( ) to read in the input, which will protect against buffer overflow (that is, writing beyond the bounds of the array.)

Same for strDataStore. Note that you are using getline( ) reading into it from the file, but again, it has no memory allocated.

When you use strcmp( ) you need to either store the return value or use the function's return as a condition in a branching right then and there. Remember that it returns a value less than 0, 0 or greater than 0. It does not give a correct true/false evaluation - actually it's backwards, in that 0 (false) return indicates a match.

If all you're trying to match is the first name, which one would expect is the first item on the data file line, you could use getline( ) with blank space as the delimiter, so you read in only first name. Then read the rest of the line into another string, using newline as delimiter.

while ( in.getline( strFirstName, 50, ' ' ) )
{
      in.getline( strRestOfLine, 100, '\n' );
     //compare the first name, do stuff
}

Oh, watch out for the semicolon following the while( in.getline( )...) - that's going to make your loop just read through the whole file and do nothing to it.

update of my code new question.

// ProjectDevelopment.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream> // This libary allows standard input and output operations. 
#include <string> // strings are used as tempory storage - for the input to a text based file
#include <vector> // at one point in my program i expermented with vectors for data storage
using namespace std; // (or maybe std::getline;, std:: string;, std:: cout; , std:: cin; (namespace howecver is a short hand version to reduce code and possible errors. 
#include <fstream> // this allows filestreaming and allows the reading and writing of a file
#include <iomanip>
#include <cstring>
int intEnterANumber;
int intConfirmation;



ifstream in ( "Store" );

string temp;
	string strConfirmation;
	string strFirstName;
	string strSurname;
	string strMiddleName;
	string strNickName;
	string strTelephoneNo;
	string strMobileNo;
	string strHouseNo; 
	string strRoadStreet; 
	string strVillageTown; 
	string strPostcode; 

int AddFirstName(int intEnterANumber)
{
cout << "Please Enter the FirstName \n";
cin >> strFirstName;

ofstream File;

File.open("Store.txt",ios::app);

File << strFirstName;
File <<" ";

File.close();



return 0;

}

int AddSurname(int intEnterANumber)
{
cout << "Please Enter the Surname \n"; 
cin >> strSurname;

ofstream File;

File.open("Store.txt",ios::app);


File << strSurname;
File <<" ";

File.close();
return 0;
}
int AddMiddleName(int intEnterANumber)
{
	cout << "Please Enter the Middle Name\n"; 
	cin >> strMiddleName;

	ofstream File;

File.open("Store.txt",ios::app);

File << strMiddleName;
File <<" ";

File.close();
	return 0;
}


int AddTelephoneNo(int intEnterANumber)
{
cout <<"Please Enter a Telephone Number\n"; 
cin >> strTelephoneNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strTelephoneNo;
File <<" ";

File.close();
return 0;
}
int AddAddress(int intEnterANumber) // a function which is called by the switch statement. 
{
cout <<"Please Enter the House No\n"; 
cin >> strHouseNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strHouseNo;
File <<" ";

File.close();


cout <<"Please Enter the road or street name\n"; // use street(ST) or (R) for road or street check validation. 
cin >> strRoadStreet; 

File.open("Store.txt",ios::app);

File << strRoadStreet;
File <<" ";

File.close();


cout <<"Please Enter the Village or town name\n"; // use Village or (VI)or Town (T) for validation check on town or street 
cin >> strVillageTown;

File.open("Store.txt",ios::app);

File << strVillageTown;
File <<" ";

File.close();

cout <<"Please Enter the Postcode\n"; 
cin >> strPostcode; // Check length during validation. With country as well we could have allowed selection of zipcodes etc. 

File.open("Store.txt",ios::app);

File << strPostcode;
File <<" ";
File <<"\n";

File.close();

return 0;
}



int main(int argc, char *argv[]) // could just be just int main  

{

    do {
  int intEnterANumber;
  cout << "Welcome To Your Phone \n\n";
  cout << " (1) Enter a New Person's Details \n";
  cout << " (2) Enter a New Person FirstName and telephone No. \n"; 
  cout << " (3) Search Phone Book for all Names \n";
  cout << " (4) Search Phone Book by Firstname n\n";
  cout << " (5)  Exit \n\n";
  cout << "Please Select A Number From the Options Above\n ";
  
 cin >> intEnterANumber;

switch (intEnterANumber)
{
case 1: AddFirstName(intEnterANumber);
AddMiddleName(intEnterANumber);
AddSurname(intEnterANumber);
AddTelephoneNo(intEnterANumber);
AddAddress(intEnterANumber);

break;
case 2: AddFirstName(intEnterANumber);
AddTelephoneNo(intEnterANumber);
break;
//case 3:
//if(!in){
 //  cout << "Cannot open file.";
  //   exit (1);
  //}
   //char str[255];
   //while(in){
   //in.getline(str, 255);      
   //cout << str << endl;
  //}
  // in.close();
//} break;

case 4:
//bits of code not quite right    

	char  strSearchData[255]; 

cout << "Please enter a name for searching \n";
cin >> strSearchData,255 ;

in.open("Store.txt");

char strDataStore[255];
char strRestOfLine[255];

while ( in.getline( strDataStore, 255, ' ' ) )
{
      in.getline( strRestOfLine, 255, '\n' );

 while(strcmp (strDataStore,strSearchData) !=0);
{
	cout << strDataStore << strRestOfLine <<endl;
}

}
  in.close();
} break;

// case 5:

// exit(EXIT_SUCCESS)
// exit(1)

	}

	while (intEnterANumber !=6 );
	
	return 0;
}



// ProjectDevelopment.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream> // This libary allows standard input and output operations. 
#include <string> // strings are used as tempory storage - for the input to a text based file
#include <vector> // at one point in my program i expermented with vectors for data storage
using namespace std; // (or maybe std::getline;, std:: string;, std:: cout; , std:: cin; (namespace howecver is a short hand version to reduce code and possible errors. 
#include <fstream> // this allows filestreaming and allows the reading and writing of a file
#include <iomanip>
#include <cstring>
int intEnterANumber;
int intConfirmation;



ifstream in ( "Store" );

string temp;
	string strConfirmation;
	string strFirstName;
	string strSurname;
	string strMiddleName;
	string strNickName;
	string strTelephoneNo;
	string strMobileNo;
	string strHouseNo; 
	string strRoadStreet; 
	string strVillageTown; 
	string strPostcode; 

int AddFirstName(int intEnterANumber)
{
cout << "Please Enter the FirstName \n";
cin >> strFirstName;

ofstream File;

File.open("Store.txt",ios::app);

File << strFirstName;
File <<" ";

File.close();



return 0;

}

int AddSurname(int intEnterANumber)
{
cout << "Please Enter the Surname \n"; 
cin >> strSurname;

ofstream File;

File.open("Store.txt",ios::app);


File << strSurname;
File <<" ";

File.close();
return 0;
}
int AddMiddleName(int intEnterANumber)
{
	cout << "Please Enter the Middle Name\n"; 
	cin >> strMiddleName;

	ofstream File;

File.open("Store.txt",ios::app);

File << strMiddleName;
File <<" ";

File.close();
	return 0;
}


int AddTelephoneNo(int intEnterANumber)
{
cout <<"Please Enter a Telephone Number\n"; 
cin >> strTelephoneNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strTelephoneNo;
File <<" ";

File.close();
return 0;
}
int AddAddress(int intEnterANumber) // a function which is called by the switch statement. 
{
cout <<"Please Enter the House No\n"; 
cin >> strHouseNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strHouseNo;
File <<" ";

File.close();


cout <<"Please Enter the road or street name\n"; // use street(ST) or (R) for road or street check validation. 
cin >> strRoadStreet; 

File.open("Store.txt",ios::app);

File << strRoadStreet;
File <<" ";

File.close();


cout <<"Please Enter the Village or town name\n"; // use Village or (VI)or Town (T) for validation check on town or street 
cin >> strVillageTown;

File.open("Store.txt",ios::app);

File << strVillageTown;
File <<" ";

File.close();

cout <<"Please Enter the Postcode\n"; 
cin >> strPostcode; // Check length during validation. With country as well we could have allowed selection of zipcodes etc. 

File.open("Store.txt",ios::app);

File << strPostcode;
File <<" ";
File <<"\n";

File.close();

return 0;
}



int main(int argc, char *argv[]) // could just be just int main  

{

    do {
  int intEnterANumber;
  cout << "Welcome To Your Phone \n\n";
  cout << " (1) Enter a New Person's Details \n";
  cout << " (2) Enter a New Person FirstName and telephone No. \n"; 
  cout << " (3) Search Phone Book for all Names \n";
  cout << " (4) Search Phone Book by Firstname n\n";
  cout << " (5)  Exit \n\n";
  cout << "Please Select A Number From the Options Above\n ";
  
 cin >> intEnterANumber;

switch (intEnterANumber)
{
case 1: AddFirstName(intEnterANumber);
AddMiddleName(intEnterANumber);
AddSurname(intEnterANumber);
AddTelephoneNo(intEnterANumber);
AddAddress(intEnterANumber);

break;
case 2: AddFirstName(intEnterANumber);
AddTelephoneNo(intEnterANumber);
break;
//case 3:
//if(!in){
 //  cout << "Cannot open file.";
  //   exit (1);
  //}
   //char str[255];
   //while(in){
   //in.getline(str, 255);      
   //cout << str << endl;
  //}
  // in.close();
//} break;

case 4:
//bits of code not quite right    

	char  strSearchData[255]; 

cout << "Please enter a name for searching \n";
cin >> strSearchData,255 ;

in.open("Store.txt");

char strDataStore[255];
char strRestOfLine[255];

while ( in.getline( strDataStore, 255, ' ' ) )
{
      in.getline( strRestOfLine, 255, '\n' );

 while(strcmp (strDataStore,strSearchData) !=0);
{
	cout << strDataStore << strRestOfLine <<endl;
}

}
  in.close();
} break;

// case 5:

// exit(EXIT_SUCCESS)
// exit(1)

	}

	while (intEnterANumber !=6 );
	
	return 0;
}

thank you - last poster it works without errors now but iam am still a very stuck noob.

when you said i need other stuff what time of stuff do i need - to complete my search. don't have to be specfic but some read up topics would be nice thanks.

Firstly, I am not going to do the functions for you, but I'll show you where you are going wrong, and give you ideas on how to correct them. The following code is extracted from your program's case 4: , with added //<MARKER (x) comments to indicate the lines that are wrong and/or unnecessary...

case 4:
{ // Added this brace for clarity
     //bits of code not quite right
     
     char* strSearchData; //< MARKER (1)
     
     cout << "Please enter a name for searching \n";
     cin >> strSearchData,255 ; //< MARKER (2)
     
     in.open("Store.txt");
     
     char* strDataStore; //< MARKER (3)
     
     while ( in.getline( strDataStore, 50)); //< MARKER (4)
     
     // tried to write token to seperate words in text file (creating split).
     //using commors. //< MARKER (5)
     
     strcmp (strDataStore,strSearchData ); //< MARKER (6)
     // sought of works cause error on intilzation.
     { // Planning to use if strcmp is true do below if false do other)
     cout << strDataStore <<endl; //< MARKER (7) <- EDIT: Ignore this marker
     in.close();
     } //< MARKER (8) <- EDIT: Ignore this marker
}
break;

//< MARKER (1) : The char* is uninitialized (memory has not been allocated for it to act as an array of characters). Its basically unusable for the purpose you have outlined it for. I would recommend for you to go through this tutorial on pointers, and their correct usage. Try the new operator to allocate memory for the char* .

EDIT: (To the OP) You have fixed this...

//< MARKER (2) : What exactly where you thinking when you wrote this? Here is a tutorial on how to use the getline function to receive a character array as input from the user, and consequentially store it in your char* .


EDIT: (To the OP) This(^) still needs to be looked into...

//< MARKER (3) : Follow the same advice I gave for //< MARKER (1) .

EDIT: (To the OP) This(^) has been fixed...

//< MARKER (4) : Check this link for information on basic File Input/Output operations. You should find an example where getline is used to read the file content. There's a (misplaced?) semicolon there as well, that probably shouldn't be, because right now, the while loop doesn't do anything useful.

EDIT: (To the OP) This(^) still needs to be looked into...

//< MARKER (5) : You mentioned that your file is delimited using commas, so your getline statement might resemble the following: getline(in, strDataStore, ',') .

EDIT: (To the OP) This(^) still needs to be looked into...

//< MARKER (6) :
Note: This statement is causing an error because you are passing uninitialized pointers into the function.
This statement should probably be inside your while loop. The function strcmp returns a value indicating whether or not the two strings are equal or not, and as you are checking for equality, it should return 0. Assuming, of course, that you have initialized your char* pointers to act as an array, and you want to check for equality, then the function strcmp will have to be put within an if(-else) construct, like the following:

if(strcmp(strDataStore, strSearchData) == 0)
{
      // Code to do whatever you want to do
}

Note: The above should be within your while(getline(....)) loop. Check this link for more information on strcmp ...


EDIT: (To the OP) This(^) still needs to be looked into...

As for your question on sorting through a list of first-names - The bubble-sort algorithm is easy to learn and apply, so I would recommend you apply this as the sorting technique. Note: You will have to load all the First-Names into a char** (array of strings) to sort it using bubble sort.
Here: A tutorial on the Bubble sort algorithm

Here: A program that shows how to implement the bubble sort algorithm for an array of strings.

Hope this helps!

EDIT: The post directly above this was posted as I was writing this... sorry about that... but the links might still be useful, as the new code also requires some tinkering...

Comments
Always solid posts :)
// ProjectDevelopment.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream> // This libary allows standard input and output operations. 
#include <string> // strings are used as tempory storage - for the input to a text based file
#include <vector> // at one point in my program i expermented with vectors for data storage
using namespace std; // (or maybe std::getline;, std:: string;, std:: cout; , std:: cin; (namespace howecver is a short hand version to reduce code and possible errors. 
#include <fstream> // this allows filestreaming and allows the reading and writing of a file
#include <iomanip>
#include <cstring>
int intEnterANumber;
int intConfirmation;



ifstream storage ( "Store.txt" );
ifstream in ( "Store.txt" );

	string strConfirmation;
	string strFirstName;
	string strSurname;
	string strMiddleName;
	string strNickName;
	string strTelephoneNo;
	string strMobileNo;
	string strHouseNo; 
	string strRoadStreet; 
	string strVillageTown; 
	string strPostcode; 

int StoreNameNumber(int intEnterANumber)
{
cout << "Please Enter the FirstName \n";
cin >> strFirstName;

ofstream Store;

Store.open("StoreNamePhone.txt",ios::app);

Store << strFirstName;

Store <<",";


cout << "Please Enter the MobilePhone \n";
cin >> strMobileNo;

Store << strMobileNo;

Store <<",";
Store <<" ";


Store.close();
return 0;
}



int AddFirstName(int intEnterANumber)
{
cout << "Please Enter the FirstName \n";
cin >> strFirstName;

ofstream File;

File.open("Store.txt",ios::app);

File << strFirstName;

File <<" ";

File.close();



return 0;

}

int AddSurname(int intEnterANumber)
{
cout << "Please Enter the Surname \n"; 
cin >> strSurname;

ofstream File;

File.open("Store.txt",ios::app);


File << strSurname;
File <<" ";

File.close();
return 0;
}
int AddMiddleName(int intEnterANumber)
{
	cout << "Please Enter the Middle Name\n"; 
	cin >> strMiddleName;

	ofstream File;

File.open("Store.txt",ios::app);

File << strMiddleName;
File <<" ";

File.close();
	return 0;
}


int AddTelephoneNo(int intEnterANumber)
{
cout <<"Please Enter a Telephone Number\n"; 
cin >> strTelephoneNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strTelephoneNo;
File <<" ";

File.close();
return 0;
}
int AddAddress(int intEnterANumber) // a function which is called by the switch statement. 
{
cout <<"Please Enter the House No\n"; 
cin >> strHouseNo;
ofstream File;

File.open("Store.txt",ios::app);

File << strHouseNo;
File <<" ";

File.close();


cout <<"Please Enter the road or street name\n"; // use street(ST) or (R) for road or street check validation. 
cin >> strRoadStreet; 

File.open("Store.txt",ios::app);

File << strRoadStreet;
File <<" ";

File.close();


cout <<"Please Enter the Village or town name\n"; // use Village or (VI)or Town (T) for validation check on town or street 
cin >> strVillageTown;

File.open("Store.txt",ios::app);

File << strVillageTown;
File <<" ";

File.close();

cout <<"Please Enter the Postcode\n"; 
cin >> strPostcode; // Check length during validation. With country as well we could have allowed selection of zipcodes etc. 

File.open("Store.txt",ios::app);

File << strPostcode;
File <<"\n";

File.close();

return 0;
}



int main(int argc, char *argv[]) // could just be just int main  

{

    do {
  int intEnterANumber;
  cout << "Welcome To Your Phone \n\n";
  cout << " (1) Enter a New Person's Details \n";
  cout << " (2) Enter a New Person FirstName and telephone No. \n"; 
  cout << " (3) Search Phone Book for all Names \n";
  cout << " (4) Search Phone Book by Firstname n\n";
  cout << " (5)  Exit \n\n";
  cout << "Please Select A Number From the Options Above\n ";
  
 cin >> intEnterANumber;

switch (intEnterANumber)
{
case 1: AddFirstName(intEnterANumber);
AddMiddleName(intEnterANumber);
AddSurname(intEnterANumber);
AddTelephoneNo(intEnterANumber);
AddAddress(intEnterANumber);

break;
case 2: StoreNameNumber(intEnterANumber);
break;
case 3:

if(!storage){
 cout << "Cannot open file.";
   exit (1);
  }
   char str[255];
   while(storage){
   storage.getline(str, 255);      
   cout << str << endl;
  }
  storage.close();
//} break;




break;

case 4:
//bits of code not quite right    

	char  strSearchData[255]; 

cout << "Please enter a name for searching \n";
cin >> strSearchData,255 ;

storage.open("Store.txt");

char strDataStore[255];
char strRestOfLine[255];
char match;

while ( storage.getline( strDataStore, 255, ',' ) )
{
     storage.getline( strRestOfLine, 255, '\n' );

 match = strcmp (strDataStore,strSearchData);

 if (match == 0)
{
	cout << strDataStore << strRestOfLine <<endl;
}
 else 
 {
    cout <<"Data Not found"; 
 }
}
  storage.close();
 break;

case 5:

exit(EXIT_SUCCESS);
exit(1);

}
	}

	while (intEnterANumber !=6 );
	
	return 0;
}

updated code still trying to work out how or where in my code i could use bubble sort to search for a particular name in a file and how to call a function that uses void. i hope the code tags are in this time.

DaniWeb engine adds line numbers in snippets only if code tag defines the language. Please, next time use code tag with the language specifier:
[code=cplusplus] source

[/code]
It's more comfortable to refer to line numbers...

Much better (compared to the other revisions)! But you still haven't fixed //< MARKER (2) from my previous post! cin will not simply accept an array of characters. You have got to use the getline statement for this as well. Replace that with the following instead:

cin.getline(strSearchData, 255, '\n');

// Behold the above code=cplusplus tags... its not very hard to use, see ArkM's post above

Also, you store the result of your string compare in a char. strcmp returns an int, so store it one. Otherwise, forget bothering to waste a whole variable to do this, and directly set it as the condition in your if-else construct, so that you'll get something like:

if(strcmp(string1, string2) == 0){ ... }

still trying to work out how or where in my code i could use bubble sort to search for a particular name in a file

Bubble sort isn't a searching algorithm. As the name implies(strongly), it is an algorithm for sorting an array's contents. If it is a searching technique that you are looking for, then try the Binary-Search algorithm. For more information on the binary-search algorithm, see this.

A sample algorithm you could follow to search for a name using B-Search:

  • Load all first names into an array of strings.
  • Apply B-Search algorithm to search for a given name

how to call a function that uses void

Which function? And what do you mean, "uses void"?

Edited 3 Years Ago by Reverend Jim: Fixed formatting

just a genearal function that has void infront of it rather than

int. i was trying to use code tags but i used not [code =cplusplus] in furure i will do so thanks for the help everyone.

binary searching you say okay will look and try thanks.[code = c++] not in furure i will do so thanks for the help everyone.

binary searching you say okay will look and try thanks.[code =cplusplus] in furure i will do so thanks for the help everyone.

binary searching you say okay will look and try thanks.

Much better (compared to the other revisions)! But you still haven't fixed //< MARKER (2) from my previous post! cin will not simply accept an array of characters. You have got to use the getline statement for this as well. Replace that with the following instead:

cin.getline(strSearchData, 255, '\n');

cin >> can be used to enter a string (array of char) - it's perhaps the simplest input method to use. But, it is also the most dangerous, as it doesn't know when to stop storing to the array. And, it cannot get a multi-word input. getline( ) is the generally better and safer choice, but not the only chooice.

But, brightsolar still has the mistake of using an unitialized pointer as the destination of that input action - a point I made in my earlier post.

> just a general function that has void infront of it rather than int.

Follow this example:

#include <iostream>

using namespace std;

void MyFunc(int num)
{
    cout << num;
}

int AnotherFunc()
{
    cout << "AnotherFunc Called!";
    return 0;
}

int main()
{
    cout << "A call to MyFunc : ";

    MyFunc(10);                       // Prints "10" in console
    AnotherFunc();                   // Prints "AnotherFunc Called!" in console
    cout << AnotherFunc();      // Prints "AnotherFunc Called!" and "0" to Console (Return value of function, AnotherFunc)

    cout << MyFunc(25);           // Invalid! Will cause an error! Function doesn't return anything to output to console!

    int num = MyFunc(25);             // Invalid!
    int nextnum = AnotherFunc();  // Valid! nextnum now holds 0

    return 0;
}

Infer the results of the above code, and you'll get the answer to your question. It also illustrates how you can use functions that return void as opposed to some other data type, and how not to use them.

> cin >> can be used to enter a string (array of char) - it's perhaps the simplest input method to use.

Whoops! Sorry for the wrong info I provided! I guess I forgot about this fact because I've been told (repeatedly) never to use this when I was learning the basics, and consequentially forgot that we can do this... :)

thanks everyone project's not complete no searching but my lecturer wanted it so did not have time to play around more with searching will try now in spare time ty.

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