-
Notifications
You must be signed in to change notification settings - Fork 0
/
sp.c
36 lines (33 loc) · 937 Bytes
/
sp.c
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
/* give me multiplkes of 3 for */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *nn(char *fname, )
{
size_t fnsz=1+strlen(argv[1]);
char *tp;
char insertstr[10]="_filtered";
char *newn=calloc(fnsz+10, sizeof(char));
tp=strrchr(argv[1], '.');
sprintf(newn, "%.*s%s%s", (int)(tp-argv[1]), argv[1], insertstr, tp);
printf("%s\n", newn);
free(newn);
return 0;
}
int main(int argc, char *argv[])
{
/* argument accounting: remember argc, the number of arguments, _includes_ the executable */
if(argc!=2) {
printf("Error. Pls supply argument (name of file).\n");
exit(EXIT_FAILURE);
}
size_t fnsz=1+strlen(argv[1]);
char *tp;
char insertstr[10]="_filtered";
char *newn=calloc(fnsz+10, sizeof(char));
tp=strrchr(argv[1], '.');
sprintf(newn, "%.*s%s%s", (int)(tp-argv[1]), argv[1], insertstr, tp);
printf("%s\n", newn);
free(newn);
return 0;
}