Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define STR_LEN 255
- #define STR_CT 20
- static
- char const * samples[STR_CT] = {
- "This is string number: 1",
- "This is string number: 2",
- "This is string number: 3",
- "This is string number: 4",
- "This is string number: 5",
- "This is string number: 6",
- "This is string number: 7",
- "This is string number: 8",
- "This is string number: 9",
- "This is string number: 10",
- "This is string number: 11",
- "This is string number: 12",
- "This is string number: 13",
- "This is string number: 14",
- "This is string number: 15",
- "This is string number: 16",
- "This is string number: 17",
- "This is string number: 18",
- "This is string number: 19",
- "This is string number: 20",
- };
- void load(size_t sz, char * strings);
- void show(size_t sz, char const * strings);
- /*
- * MARK: main()
- */
- int main(int argc, char const * argv[]) {
- char * strings = malloc(STR_LEN * STR_CT * sizeof(char));
- if (strings != NULL) {
- load(STR_CT, strings);
- show(STR_CT, strings);
- free(strings);
- }
- else {
- fprintf(stderr, "Unable to allocate working storage\n");
- }
- return 0;
- }
- /*
- * MARK: load()
- */
- void load(size_t sz, char * strings) {
- char * string = strings;
- for (size_t s_ = 0ul; s_ < sz; ++s_) {
- sprintf(string, "%s", samples[s_]);
- string += STR_LEN;
- }
- }
- /*
- * MARK: show()
- */
- void show(size_t sz, char const * strings) {
- char const * string = strings;
- for (size_t s_ = 0ul; s_ < sz; ++s_) {
- printf("%s\n", string);
- string += STR_LEN;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement