pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • Examples
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

Pebble C API

  • Pebble C API
  • Pebble JavaScript API
  • PebbleKit JS
  • PebbleKit iOS
  • PebbleKit Android
  • Foundation
    • App
    • App Communication
    • App Glance
    • AppMessage
    • AppSync
    • AppWorker
    • DataLogging
    • DataStructures
      • UUID
    • Dictation
    • Dictionary
    • Event Service
      • AccelerometerService
      • AppFocusService
      • BatteryStateService
      • CompassService
      • ConnectionService
      • HealthService
      • TickTimerService
    • Exit Reason
    • Internationalization
    • Launch Reason
    • Logging
    • Math
    • Memory Management
    • Platform
    • Resources
      • File Formats
    • Storage
    • Timer
    • Wakeup
    • Wall Time
    • WatchInfo
    • Rocky
  • Graphics
    • Draw Commands
    • Drawing Paths
    • Drawing Primitives
    • Drawing Text
    • Fonts
    • Graphics Context
    • Graphics Types
      • Color Definitions
  • User Interface
    • Animation
      • PropertyAnimation
    • Clicks
    • Layers
      • ActionBarLayer
      • BitmapLayer
      • MenuLayer
      • RotBitmapLayer
      • ScrollLayer
      • SimpleMenuLayer
      • StatusBarLayer
      • TextLayer
    • Light
    • Preferences
    • UnobstructedArea
    • Vibes
    • Window
      • ActionMenu
      • NumberWindow
    • Window Stack
  • Standard C
    • Format
    • Locale
    • Math
    • Memory
    • String
    • Time

Format

Standard formatting.

If you're looking for input/output functions, check out the Logging API.

Function Documentation

int snprintf(char * str, size_t n, const * fmt, ...)

Format a string into a buffer.

The Pebble-supported format specifiers are displayed below.


Specifier Output Example
d or i Signed decimal integer 294
u Unsigned decimal integer 7235
o Unsigned octal 610
x Unsigned hexadecimal integer 8b2
X Unsigned hexadecimal integer (uppercase) 8B2
c Character h
s Null-terminated string of characters pebble
p Pointer address 0xb8000000
% A % followed by another % character will write a single % to the stream. %

Length specifiers can also be combined with the format specifiers above:

u o x X c s p n
(none) unsigned int int char* void* int*
h unsigned short int short int*
l unsigned long int wint_t wchar_t* long int*

Parameters

str

The string buffer to write the formatted string into

n

The maximum size of the buffer

fmt

The C formatting string

Returns

The number of bytes written

Need some help?

Functions

  • snprintf

Getting Help

Do you have questions about the Pebble SDK?

Do you need some help understanding something on this page?

You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!