Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ void to avoid functions

/*The following example collects user data and formats it using seperate void
statements */
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

// function declarations
void inputData();
void displayData();

string name, addr1, addr2, postalCode;
// the main method1
int main()
{
    inputData();
    displayData();

    return 0;
}

// the first function definition
void inputData()
{
    cout << "Kindly provide your address details 
"
         << "Name: ";
    getline(cin, name);
    cout << "Address1: ";
    getline(cin, addr1);
    cout << "Address2: ";
    getline(cin, addr2);
    cout << "PostalCode: ";
    getline(cin, postalCode);
}

// the second function definition
void displayData()
{
    //system("cls"); exists for DOS or cmd windows
    system("cls"); //system("clear") for Linux or MacOS
    cout << name
         << "
"
         << addr1
         << "
"
         << addr2
         << "
"
         << postalCode << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: # in c++ 
Cpp :: https://www.google 
Cpp :: c++ linker input and output 
Cpp :: Remove the jth object from the subset 
Cpp :: castin in C++ 
Cpp :: ue4 foreach loop c++ 
Cpp :: c++ to assembly 
Cpp :: columntransformer onehotencoder 
Cpp :: for in c++ example 
Cpp :: button creation in C++ GUI 
Cpp :: how to define global array in c++ in a scope 
Cpp :: how to find second smallest element using single loop 
Cpp :: convert c++ code to exe 
Cpp :: The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 . 
Cpp :: get array size 
Cpp :: gcd of two number in c++ stl 
Cpp :: multiply two arbitrary integers a and b (a greater than b) 
Cpp :: amusia 
Cpp :: passing a 2d array cpp 
Cpp :: c++ & operator 
Cpp :: c++ split string by sstream 
Cpp :: c++ quicksort 
Cpp :: Come concatenare stringhe in c++ 
Cpp :: opengl text rendering with 3d rendering 
C :: how to use gotoxy in c language 
C :: convert from integer to string vb 
C :: check if string starts with c 
C :: prime chec kin c 
C :: successeur nombre chaine 
C :: how to ban websites on mac 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =