title: Decoding what these Valgrind debugger memory errors mean within my code
body: <p>Fairly new student to c here. Just finished setting up a Linux subsytem so i can run Valgrind for debugging purposes. I'm working on an assignment that requires multiple arrays of strings, and organized storing of those values. I believe the logic of my code is sound, however when running it immediately exits the process leaving no time for me to even input the n number of times the program will run. I believe this is a segmentation fault, and downloaded valgrind to pinpoint the problem. However i am having trouble understanding what these error messages mean. It seems there is only one or two errors, but i could be wrong. I may need to use dynamic memory functions (malloc, calloc...) to make it work, but i am even more of a beginner when it comes to memory allocation and am not sure even where to start. Any advice on what my valgrind errors mean, or how i should go about dynamically allocating memory would be greatly appreciated :)</p>
  
  <p>Any additional information anyone needs, feel free to ask.</p>
  
  <p>Ive eliminated any error that showed up that i knew could be solved. Now only these two remain. I believe it has something to do with a segmentation fault or not allocating memory correctly, but i am not sure.</p>
  
  <p>Here is my current code. It may be a bit messy, or have bad whitespace. I am also open to criticism on my coding style :)</p>
  
  <pre><code>    int main() {
  int n, i, j = 0, k, m, p, flag, key, count;
  char choiceUQ, choiceSS[100];
  char nameTemp[100], printStu[n][100];
  char stuName[n][100], stuSym[n][n][100];        
  
  scanf("%d", &amp;n); //Scan in n number of times u or q will run
  
  for(i = 0; i &lt; n; i++) { //initialize all symptoms to be null for later if statement.
      for(k = 0; k &lt; n; k++) {
          strcpy (stuSym[k][i], "");
      }
  }
  
  for(i = 0; i &lt; n; i++) {
      strcpy(nameTemp, "");
      scanf("%c", &amp;choiceUQ);
      if(choiceUQ == 'u') { 
          flag = 0; //set flag to 0, will be changed if name is already in database.
          scanf("%s", nameTemp);
          for(k = 0; k &lt; i; k++) { //for loop checks if name is already in database.
              if(nameTemp == stuName[k]) { 
                  flag = 1; //sets flag if name is in database.
                  for(m = 0; m &lt; i; m++) { //checks for next available string array spot for symptoms.
                      if(stuSym[m][k] == "")
                         scanf("%s", stuSym[m][k]);
                  }
              }
          }
          if(flag == 0) { //checks for set flag, if no flag is set, it is a new name, so symptom spot will always be 0.
             strcpy(stuName[i], nameTemp);
             scanf("%s", stuSym[0][i]);
          }
  }
      if(choiceUQ == 'q') {
          scanf("%s", choiceSS); //checks for input student or symptom, and executes code related to it.
          if(choiceSS == "student") {
              scanf("%s", nameTemp);
              for(k = 0; k &lt; i; k++) { //searches for student name in database
                  if(nameTemp == stuName[k]) 
                      key = k;
              }
              for(m = 0; m &lt; i; m++) {
                  printf("%s\n", stuSym[m][key]); //prints all symptoms that student has reported
              }
          }
          if(choiceSS == "symptom") {
              count = 0; //initialize count of symptoms at 0
              scanf("%s", nameTemp);
              for(k = 0; k &lt; i; k++) {
                  for(m = 0; m &lt; i; m++) {
                     if(nameTemp == stuSym[m][k]) { //nested for loops lead to if loop to check if each student has the given symptom
                        strcpy(printStu[count], stuName[k]);
                        count++;
                      }
                  }
              }
              for(p = 0; p &lt; count; p++) { //prints all students copied into printStu array
                  printf("%s", printStu[p]);
              }
          }
      }      
  }
  
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>The error i am getting in valgrind is shown below</p>
  
  <pre><code>==4540== error calling PR_SET_PTRACER, vgdb might block
  
  ==4540== Use of uninitialised value of size 8
  ==4540==    at 0x108B9C: main (santos_pandemic2.c:12)
  
  
  ==4540== Use of uninitialised value of size 8
  ==4540==    at 0x4EB7EC0: __isoc99_scanf (isoc99_scanf.c:27)
  
  ^[[A
  
  ==4540== Conditional jump or move depends on uninitialised value(s)
  ==4540==    at 0x108C20: main (santos_pandemic2.c:14)
  
  ==4540== Conditional jump or move depends on uninitialised value(s)
  ==4540==    at 0x109115: main (santos_pandemic2.c:20)
  
  ==4540== HEAP SUMMARY:
  ==4540==     in use at exit: 0 bytes in 0 blocks
  ==4540==   total heap usage: 1 allocs, 1 frees, 4,096 bytes allocated
  
  ==4540== All heap blocks were freed -- no leaks are possible
  </code></pre>