Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

write variable to file cpp

int main()
{
    char name[20], phone[20];

    cout<< "Enter your name: ";
    cin>> name;
    cout<< "Enter you phone number: ";
    cin>> phone;

    ofstream file_w ("test.txt");

    file_w << name <<endl
           << phone<<endl;

    cout << "Process complete";
    file_w.close();
  
    return 0;
}
 
PREVIOUS NEXT
Tagged: #write #variable #file #cpp
ADD COMMENT
Topic
Name
6+9 =