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 8391693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:19:38+00:00 2026-06-09T19:19:38+00:00

In GNU Octave, I’m getting an error with this code. A = cell(10,1); A{5,1}

  • 0

In GNU Octave, I’m getting an error with this code.

A = cell(10,1);
A{5,1} = "foobar";
outputFile = fopen("mytext.txt", "w");
printf(outputFile, "%s", A{5,1});

I get this error:

error: printf: format TEMPLATE must be a string

This error message is not Helpful, The google does not know what this error is! what is wrong?

  • 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-09T19:19:40+00:00Added an answer on June 9, 2026 at 7:19 pm

    Found the solution to this error.

    The very first parameter you are passing into printf MUST be a valid format string. You are passing it a file handle. If you want to pass a file handle, you should be using fprintf instead. If you specify a first parameter as a file, printf gives you the above error.

    You should be doing this instead:

    A = cell(10,1);
    A{5,1} = "foobar";
    outputFile = fopen("mytext.txt", "w");
    fprintf(outputFile, "%s", A{5,1});        
    

    Or, if you wanted to print to the screen, remove the outputFile parameter:

    A = cell(10,1);
    A{5,1} = "foobar";
    outputFile = fopen("mytext.txt", "w");
    printf("%s", A{5,1});
    % Here printf successfully casts the cell as a string.  no error.
    

    You are passing bad parameters to printf and Octave tries to make sense of nonsense. Review this webpage to see what can and cannot be passed into octave’s printf:

    http://www.gnu.org/software/octave/doc/interpreter/Formatted-Output.html#doc-printf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Matlab or GNU Octave I'd like to do something like this: x=struct('a',1,'b',2,'c',[1 2;3
GNU bash, version 4.2.24: $> printf %.0f, %.0f\n 48.5 49.5 48, 50 Ruby 1.8.7
(this is similar to GNU make: Execute target but take dependency from file but
I'm using gnu as for a simple boot. It's something like this: .text .org
I recently downloaded the latest stable release of Gnu Octave, and was attempting to
GNU Emacs 23.1.1 I am maintaining someones code. There are many files and directories
GNU libc's backtrace and In-circuit emulators/debuggers are not always available when porting code to
Running GNU Emacs 22.2.1 on Ubuntu 9.04. When editing python code in emacs, if
I'm trying to write a function in GNU Octave that does bilinear interpolation on
What's wrong with my code? octave:26> plot([1;2;3;4],[1;8;27;64], 'marker', 'o', 'linestyle', 'none', 'marker', 'o', 'markeredgecolor',

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.