CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Threaded View

  1. #1
    Join Date
    Dec 2015
    Posts
    9

    c++ Structures export data for specific name, country, last name

    That is the structure that I created:

    Code:
    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;
    
    
    struct Students
    {
    	char first_name[10];
    	char last_name[10];
    	char country[20];
    
    
    };
    int main()
    {
    	Students array[10];
    	int n, i;
    	cin >> n;
    
    	for (i = 0; i < n; i++)
    	{
    		cout << "Name:";
    		cin >> array[i].first_name;
    		cout << "Last Name:";
    		cin >> array[i].last_name;
    		cout << "Country:";
    		cin >> array[i].country;
    
    	}
    
    	for (i = 0; i < n; i++)
    	{
    		cout << array[i].first_name << " ";
    		cout << array[i].last_name << " ";
    		cout << array[i].country << " ";
    
    
    	}
    	system("pause");
    
    
    }

    And I have to write code that once I enter John (for example) displays all information about him: last name, country. And when I enter country to export: first name, last name. Maybe I don't explain it properly. Because my english is bad. Maybe that's the reason that i can't find specific information or similar examples.

    Code:
    Ouput example:
    n=2
    Name:John
    Last Name: Doe
    Country: England
     
    Name:Pete
    Last Name: Donaldson
    Country: USA
    
    Name:John
    Last Name: Peterson
    Country: England
     
    
     
    And that's the part that i can't do:
     
    /Info about student/
    Enter Name for check:
    John
     
    and here the output must be:
    Name:John
    Last Name: Doe
    Country: England
    
    Name:John
    Last Name: Peterson
    Country: England
     
    another check: 
    if I enter Pete:
    Name:Pete
    Last Name: Donaldson
    Country: USA
    The same think for country, when if I enter England:
    Name:John
    Last Name: Doe
    Country: England

    Name:John
    Last Name: Peterson
    Country: England
    Last edited by fr4234; January 2nd, 2016 at 01:44 PM.

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
  •  





Click Here to Expand Forum to Full Width

Featured