aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2014-02-06 16:16:18 +0100
committerSalvatore Sanfilippo <antirez@gmail.com>2014-02-06 16:16:18 +0100
commit05e73e47cb15eeeb620ca4a608d0f3797a61a328 (patch)
tree46b55e3688894f53aea9b54acd75929c3d8f8f69 /README.md
parentd3bf159cf8c44655e63009b50d96e68dbf929706 (diff)
parentabca3e4caa4c3b95f678d769219ba97d906bd569 (diff)
downloadsds-05e73e47cb15eeeb620ca4a608d0f3797a61a328.tar.xz
Merge pull request #1 from frodsan/patch-1
Fix markdown.
Diffstat (limited to 'README.md')
-rw-r--r--README.md45
1 files changed, 26 insertions, 19 deletions
diff --git a/README.md b/README.md
index 161b87f..d717ea4 100644
--- a/README.md
+++ b/README.md
@@ -118,38 +118,45 @@ Creating SDS strings
There are many ways to create SDS strings:
-The `sdsnew` function creates an SDS string starting from a C null terminated string. We already saw how it works in the above example. The `sdsnewlen` function is similar to `sdsnew` but instead of creating the string assuming that the input string is null terminated, it gets an additional length parameter. This way you can create a string using binary data:
+* The `sdsnew` function creates an SDS string starting from a C null terminated string. We already saw how it works in the above example.
+* The `sdsnewlen` function is similar to `sdsnew` but instead of creating the string assuming that the input string is null terminated, it gets an additional length parameter. This way you can create a string using binary data:
- char buf[3];
- sds mystring;
- buf[0] = 'A';
- buf[1] = 'B';
- buf[2] = 'C';
- mystring = sdsnewlen(buf,3);
- printf("%s of len %d\n", mystring, (int) sdslen(mystring));
+ char buf[3];
+ sds mystring;
+
+ buf[0] = 'A';
+ buf[1] = 'B';
+ buf[2] = 'C';
+ mystring = sdsnewlen(buf,3);
+ printf("%s of len %d\n", mystring, (int) sdslen(mystring));
- output> ABC of len 3
+ output> ABC of len 3
+
Note: `sdslen` return value is casted to `int` because it returns a `size_t`
type. You can use the right `printf` specifier instead of casting.
-The `sdsempty()` function creates an empty zero-length string:
+* The `sdsempty()` function creates an empty zero-length string:
+
+
+ sds mystring = sdsempty();
+ printf("%d\n", (int) sdslen(mystring));
+
+ output> 0
+
- sds mystring = sdsempty();
- printf("%d\n", (int) sdslen(mystring));
+* The `sdsdup()` function duplicates an already existing SDS string:
- output> 0
-Finally the `sdsdup()` function duplicates an already existing SDS string:
+ sds s1, s2;
- sds s1, s2;
+ s1 = sdsnew("Hello");
+ s2 = sdsdup(s1);
+ printf("%s %s\n", s1, s2);
- s1 = sdsnew("Hello");
- s2 = sdsdup(s1);
- printf("%s %s\n", s1, s2);
+ output> Hello Hello
- output> Hello Hello
Obtaining the string length
---