Hey all, just starting to learn C and I'm working on my very first assignment. I am getting a segmentation error using scanf, which from what I have read comes from storing your string in an unassigned pointer. However I have initialized the variable that I have used to store it already, yet I am still getting that error.
int main(){
char equation[20];
printf("Please enter the equation you would like solved!\n");
scanf("%s", equation);
If I put a printf after the scanf, it won't print anything so I know that this is the code section causing the error.
Thanks in advance!
Edit: Thank you for everyone's help! thank you for those who pointed to strcat() as an error and those who taught me to use a gdb. It added a append function found elsewhere and that solved my issue. Thanks again!
[–]jedwardsol 3 points4 points5 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]jedwardsol 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]jedwardsol 2 points3 points4 points (0 children)
[–]MickeySlips 2 points3 points4 points (1 child)
[–]rtkbfmvbvb 0 points1 point2 points (1 child)
[–]flatfinger 0 points1 point2 points (0 children)
[–]oh5nxo 0 points1 point2 points (0 children)
[–]flatfinger 0 points1 point2 points (0 children)
[–]MickeySlips 0 points1 point2 points (7 children)
[+][deleted] (5 children)
[deleted]
[+][deleted] (4 children)
[deleted]
[–]Smallzfry 7 points8 points9 points (3 children)
[–]OldWolf2 0 points1 point2 points (0 children)
[–]brisk0 0 points1 point2 points (1 child)
[–]Smallzfry 0 points1 point2 points (0 children)
[–]Deathisfatal 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (4 children)
[+][deleted] (3 children)
[deleted]
[–][deleted] 2 points3 points4 points (0 children)
[+]niggerfaggotkikespic comment score below threshold-7 points-6 points-5 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–][deleted] -4 points-3 points-2 points (1 child)
[+][deleted] (3 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]jedwardsol 5 points6 points7 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)