Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7193

My program exits after trying to copy strings to an array of structures [closed]

$
0
0

So I'm trying to make a phonebook program and am in the process of coding something to remove an entry. To do so, I ask the user to enter a name, search an array of strcutres for that name, then change copy 'NULL' to the elements of said array using strcpy() so it's freed for use. The thing is, I can't even be sure if I did it correctly because the program just exits almost immediately after. I've done this before successfully with adding an entry as well as changing every element to 'NULL' at the start of my program, so why is it doing this now?

A portion of what the code looks like:A portion of what the code looks like

What ends up happening:What ends up happening

(Sidenote: I've only been coding for 2 months so I'm very sorry for how amatuer this all looks and probably sounds. This is also for an assignment so I'll get accused of cheating if I use anything not in the libraries <stdio.h>, <string.h>, and <stdlib.h>)

At first I thought it was an issue with scanf() since that's given me issues before, but that doesn't seem to be the case. I also tried printing out the array contents after deleting the entry by rearranging the code, but it seemed to skip past that as well. The code I'm presenting takes place inside of a switch structure if that helps.


Viewing all articles
Browse latest Browse all 7193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>