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

String

Standard C-string manipulation.

Function Documentation

int strcmp(const char * str1, const char * str2)

Compares the null terminated strings str1 and str2 to each other.

Parameters

str1

The first C string to compare

str2

The second C string to compare

Returns

The difference of the first differing pair of bytes or 0 if the strings are identical

int strncmp(const char * str1, const char * str2, size_t n)

Compares the null terminated strings str1 and str2 to each other for up to n bytes.

Comparison ends when a null is read or when n bytes are read, whichever happens first.

Parameters

str1

The first C string to compare

str2

The second C string to compare

n

The maximum number of bytes to compare

Returns

The difference of the first differing pair of bytes or the final pair of bytes read or 0 if the portions of the strings read are identical

char * strcpy(char * dest, const char * src)

Copies the string in src into dest and null terminates dest.

There should be no overlap of dest and src in memory.

Parameters

dest

The destination buffer with enough space for src

src

The source C string

Returns

The destination buffer dest

char * strncpy(char * dest, const char * src, size_t n)

Copies up to n bytes from the string in src into dest and null terminates dest.

If dest is null terminated before n bytes have been written, null bytes will continue to be written until n bytes total were written. There should be no overlap of dest and src in memory.

Parameters

dest

The destination buffer with enough space for n bytes

src

The source string

n

The number of bytes to copy

Returns

The destination buffer dest

char * strcat(char * dest, const char * src)

Concatenates the string in src to the end of the string pointed by dest and null terminates dest.

There should be no overlap of dest and src.

Parameters

dest

The destination buffer with enough space for src beyond the null character

src

The source C string

Returns

The destination buffer dest

char * strncat(char * dest, const char * src, size_t n)

Concatenates up to n bytes from the string in src to the end of the string pointed by dest and null terminates dest.

There should be no overlap of dest and src in memeory.

Parameters

dest

The destination buffer with enough space for src beyond the null character

src

The source string

n

The maximum number of bytes to copy

Returns

The destination buffer dest

size_t strlen(const char * str)

Calculates the length of a null terminated string.

Parameters

str

The C string.

Returns

The length of the C string str.

Need some help?

Functions

  • strcmp
  • strncmp
  • strcpy
  • strncpy
  • strcat
  • strncat
  • strlen

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!