🔒 Closed Visual c++

Status
Not open for further replies.
Here's an example code for input fields for last name, first name and middle name that transfers data to Excel after clicking save using Visual C++:

C++:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
    string firstName, lastName, middleName;
    cout << "Enter first name: ";
    getline(cin, firstName);
    cout << "Enter middle name: ";
    getline(cin, middleName);
    cout << "Enter last name: ";
    getline(cin, lastName);
    
    string fileName = "data.csv";
    ofstream outputFile;
    outputFile.open(fileName, ios::app);

    outputFile << firstName << "," << middleName << "," << lastName << "\n";

    outputFile.close();

    return 0;
}

This code prompts the user to enter the first name, middle name, and last name, and saves it to a CSV file named "data.csv". The data is separated by commas and each record is separated by a new line character.

You can customize this code to fit your needs and integrate it with Excel by importing the CSV file.
 
Here's an example code for input fields for last name, first name and middle name that transfers data to Excel after clicking save using Visual C++:

C++:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
    string firstName, lastName, middleName;
    cout << "Enter first name: ";
    getline(cin, firstName);
    cout << "Enter middle name: ";
    getline(cin, middleName);
    cout << "Enter last name: ";
    getline(cin, lastName);
   
    string fileName = "data.csv";
    ofstream outputFile;
    outputFile.open(fileName, ios::app);

    outputFile << firstName << "," << middleName << "," << lastName << "\n";

    outputFile.close();

    return 0;
}

This code prompts the user to enter the first name, middle name, and last name, and saves it to a CSV file named "data.csv". The data is separated by commas and each record is separated by a new line character.

You can customize this code to fit your needs and integrate it with Excel by importing the CSV file.
what if I want it to be separated by different colums?
 
what if I want it to be separated by different colums?
To separate the data by different columns, you can modify the code to use a different delimiter. For example, if you want to separate the data by tabs, you can use the '\t' character as the delimiter by replacing the comma in the output stream.

Here's an example code for input fields for last name, first name, and middle name that transfers data to Excel after clicking save using Visual C++ and separates the data by tabs:

C++:
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main() {
    string firstName, lastName, middleName;
    cout << "Enter first name: ";
    getline(cin, firstName);
    cout << "Enter middle name: ";
    getline(cin, middleName);
    cout << "Enter last name: ";
    getline(cin, lastName);

    string fileName = "data.csv";
    ofstream outputFile;
    outputFile.open(fileName, ios::app);

    outputFile << firstName << "\t" << middleName << "\t" << lastName << "\n";

    outputFile.close();

    return 0;
}

This code saves the data to a CSV file named "data.csv" and separates the data by tabs. You can customize this code to fit your needs and integrate it with Excel by importing the CSV file and setting the delimiter to tabs.
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 370
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,155
Guests online
861
Total visitors
2,016

Forum statistics

Threads
2,273,748
Posts
28,951,295
Members
1,234,942
Latest member
nuzlock
Back
Top