Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // OS HW 1
- //
- // Created by drew mcdaniel on 2/11/16.
- //
- //
- #include <stdio.h>
- char* concat_strings(char** strings);
- int main(int argc, char** argv){
- //TODO: first make sure the proper # of arguments are passed
- if (argv == NULL) {
- printf("ERROR");
- }
- //argc is argument count, default 1 (filepath)
- //argv is array of arguments passed in
- printf("%s is the first string %s is the second string\n", argv[1], argv[2]);
- //prints inputted strings
- concat_strings(argv);
- return 0;
- }
- char* concat_strings(char** strings){
- char* str;
- str = (char*) malloc(80);
- strings++;
- /* Initial memory allocation */
- str = *strings;
- printf("String = %s\n", str);
- while (strings != 0) {
- /* Reallocating memory */
- strings++;
- str = (char*) realloc(str, 80);
- while(*str != 0){
- if (str == 0) {
- str = " ";
- str++;
- str = *strings;
- }else{
- str++;
- }
- }
- printf("String = %s\n", str);
- }
- return str;
- /*
- char* final = strings[2]-1;
- final = " ";
- return strings[1];
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement