aboutsummaryrefslogtreecommitdiff
path: root/3.3.c
diff options
context:
space:
mode:
authorsinanmohd <pcmsinan@gmail.com>2022-06-04 12:50:05 +0530
committersinanmohd <pcmsinan@gmail.com>2022-06-04 12:50:05 +0530
commit33f3e3f2bdd7e4eaf89e9708505d3c0d27fc23f7 (patch)
tree0f8222ea928953745d7bd17816c90f78d7ff55df /3.3.c
parent00af3bb6a98925c1b997f3b077615627e31ba24c (diff)
rewrite deleted 3.3.c (whole reason to make this git repo)
Diffstat (limited to '3.3.c')
-rw-r--r--3.3.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/3.3.c b/3.3.c
new file mode 100644
index 0000000..e27078c
--- /dev/null
+++ b/3.3.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+
+#define MAXLEN 1000
+
+char* expand(char coom[], char str[]);
+
+int
+main(void)
+{
+ char coom[] = "sneed a-z a-b-c a-z0-9 -a-z sneed";
+ char str[MAXLEN];
+
+ printf("%s\n%s\n", coom, expand(coom, str));
+
+ return 0;
+}
+
+char*
+expand(char from[], char to[])
+{
+ int i, j, k;
+
+ for (i = 0, j = 0; from[i] != '\0'; i++) {
+ to[j++] = from[i];
+
+ for (k = from[i]+1; ((from[i] >= '0' && from[i] <= '9') || (from[i] >= 'a' && from[i] <= 'z') || (from[i] >= 'A' && from[i] <= 'Z')) && from[i+1] == '-' && k < from[i+2]; k++, j++)
+ to[j] = k;
+
+ if (from[i+1] == '-' && ((from[i] >= '0' && from[i] <= '9') || (from[i] >= 'a' && from[i] <= 'z') || (from[i] >= 'A' && from[i] <= 'Z')))
+ i++;
+ }
+
+ to[j] = '\0';
+
+ return to;
+}