-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
40 lines (35 loc) · 751 Bytes
/
main.c
File metadata and controls
40 lines (35 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
/*
* Lab program that takes two different programs
* First one:
*
*/
int outputSize = 4;
int arraySize = 3;
int toArgv(char* source, char* dest[], int size)
{
int destinationSize = 1;
char *delimit;
delimit = strtok(source," ");
dest[0] = delimit;
while(destinationSize != size)
{
delimit = strtok(NULL," ");
dest[destinationSize] = delimit;
destinationSize++;
}
return destinationSize;
}
int main(int argc, char *argv[]) {
char string[] = "sample string also this";
char* output[sizeof(char) * outputSize];
int counter = toArgv(string,output,5);
for(int i =0 ; i != counter; ++i)
{
printf("%d|-->'%s'\n", i, output[i]);
}
//Print output
}