Posted March 8, 201410 yr Hey, I'm pretty new to Linux/C programming and I have a problem with the following code: Code: #include <stdio.h> #include <string.h> #include <stdlib.h> int main (int argc, char **argv){ char set1[strlen(argv[1])]; char set2[strlen(argv[2])]; for (int y=0; y< strlen(argv[1]); y++){ set1[y] = *(argv[1]+y); set2[y] = *(argv[2]+y); } printf("%s \n", set1); printf("%s \n", set2); } (the arguments are 2 strings of the same length) well this still works fine. But after adding: Code: char text[23]; while (fgets(text, 23, stdin) != 0){ } anywhere set1 and set2 get random values. Any ideas how to fix that or what I'm doing wrong? (I'm not sure if this is the right area for this post, sorry if not) Continue reading...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.