Home
  • Products
  • Solutions
  • Support
  • Company
  • Products
  • Solutions
  • Support
  • Company
Community PCB Design Allegro PCB Editor and PCB SKILL How to fix the common SKILL error “fprintf/sprintf: format...

Stats

  • Replies 2
  • Subscribers 149
  • Views 130
  • Members are here 0
More Content

How to fix the common SKILL error “fprintf/sprintf: format spec. incompatible with data”

PCBTech
PCBTech 11 days ago

For formatted output, SKILL provides the printf, fprintf, and sprintf standard C studio library routines. This error occurs if the data type of a variable does not match the format specifier.

There are two ways to fix this:

  1. Change the format specifier to match the data. In the example, change the format specifier from string (%s) to integer (%d):

              a=5
              printf("a is: %d:\n" a); instead of printf("a is: %s:\n" a)

  1. Change the data to match the format specifier:

              a=” a string”; instead of defining it as a number like in the previous example
              printf("a is: %s:\n" a)

To know about the common output specifiers, click here.

Team PCBTech

Cadence Design Systems

  • Reply
  • Cancel
  • Cancel
  • eDave
    eDave 11 days ago

    Another option, if you are unsure of the data type, is to use %L

    printf("%L\n", 1) returns 1

    printf("%L\n", 1.0) returns 1.0

    printf("%L\n", "a") returns "a"

    printf("%L\n", t)  returns t

    printf("%L\n", list(1 1.0 "a" t)) returns (1 1.0 "a" t)

    • Cancel
    • Up +1 Down
    • Reply
    • Cancel
  • HJerry
    HJerry 3 days ago

    Or,

    Check what type the data is using type(a) and use the correct format specifier.

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2023 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information