Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:46:34+00:00 2026-06-05T10:46:34+00:00

So now that I figured out how to write to an excel file (Thank

  • 0

So now that I figured out how to write to an excel file (Thank you guys so much for that!), I’m wondering if there is a way to write to a second column in excel. I’m actually sending two different variables to this excel file and I’d like them side-by-side as opposed to right next to each other. I didn’t see any other questions asking this for the C language, so thought I’d throw it out that. If there is one, feel free to link me the question and I apologize for wasting the space!

File * fp;
fp = fopen("C:\\Documents and Settings\\MyName\\Desktop\\Filename.csv", "w");
if(fp == NULL){
    printf("Couldn't open file\n");
    return;
}
for (j = 0; j<Variable0; j++){
fprintf(fp, "%f\n", (j+Variable1);
fprintf(fp, "%f\n", (j+Variable2);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:46:37+00:00Added an answer on June 5, 2026 at 10:46 am

    You are not writing an Excel file, you are writing a comma-separated value file (CSV). It can however, still be opened with Excel. There is a huge difference. Each column is separated with a comma. Each row is seperated by a newline character.

    File * fp;
    fp = fopen("C:\\Documents and Settings\\MyName\\Desktop\\Filename.csv", "w");
    if(fp == NULL){
        printf("Couldn't open file\n");
        return;
    }
    
    float otherVar1 = 1.0f; // random thing you want to put in second column
    float otherVar2 = 2.0f; // random thing you want to put in second column
    
    for (j = 0; j<Variable0; j++){
        fprintf(fp, "%f,%f\n", (j+Variable1), (otherVar1));
        fprintf(fp, "%f,%f\n", (j+Variable2), (otherVar2));
    }
    

    Make sure you remember to close the file as well!

    fclose(fp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now that I know I can no longer communicate with Twitter mashups out there,
I thought I had this all figured out, but now that I'm writing a
Now that ASP.NET MVC 2 is out , I tried to install it on
Now that C++ development has become second nature to me, do I have to
I figured out how to create a static method that is available everywhere, for
I want to write an android application that can parse files. I have figured
I'm wondering if there is an event that can be handled or a method
I am using NLog for the first time, i figured out how to write
I'm trying to figure out how to write a pre-commit hook for Git that
Okay so I have the ability to write the XML to an excel file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.