C program behaves differently in gcc and llvm compiler -
i wrote program consists of main , function expand. problem code returns intended result when compiled , run xcode (latest version) when compiled , run gcc compiler through terminal code stuck after running (no warnings or errors!). command use compile code in terminal:
gcc expand.c -o expand -wall -pedantic -ansi
below code. have no idea problem is:
#include <stdio.h> #define max_len 100 #define atoi_gap 48 void expand(char s1[], char s2[]); int main() { int i; char s2[max_len]; /* declare target array */ char s1[4]; /* declare source array */ s1[0] = 'a'; s1[1] = '-'; s1[2] = 'z'; s1[3] = '\0'; for(i = 0; < max_len; ++i) { /* print s2 array */ printf("%d ", s2[i]); } expand(s1, s2); for(i = 0; s2[i] != '\0'; ++i) { /* print s2 array */ printf("%c ", s2[i]); } return 0; } /* function gets string s1 of format "letterx-lettery" , fills "-" consequent letters letterx lettery. example, if s1 = "a-d", s2 "abcd"*/ void expand(char s1[], char s2[]) { int start = s2[0] = s1[0]; /* first letter of array s2 same of array s1 */ int stop = s1[2]; /* determine @ letter need stop */ int j; printf("inside expand"); for(j = 1; j < stop - '0' - atoi_gap; ++j) { s2[j] = ++start; /* fill in gap */ } s2[j] = '\0'; printf("finished expand"); }
found issue, incorrectly running output c file. exported path c output files, call file in question typing "filename" in terminal. however, exported path wasn't sourced wasn't getting result. when run file "./filename" working.
Comments
Post a Comment