Why shows garbage value | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
31st Jul 2020, 3:32 PM
Samarendra Singh
Samarendra Singh - avatar
6 Answers
+ 2
There are lots of scanf and printf problems in your code. I fixed a lot of the issues here: https://code.sololearn.com/cOgMZj6Vh3fi If you want to read each digit as a separate int in your int array, you need a loop. Similar is needed for printing that data structure. My changes implement the necessary scan and print functions. Also, I'm sure you want to copy values from ISBN to gsi and so on. The other way is copying from garbage to user input which makes no sense.
31st Jul 2020, 4:14 PM
Josh Greig
Josh Greig - avatar
+ 2
Your assigning uninitialized values in to ISBN in all loops... Ex: ISBN[i]=gsi[i]; here gsi[i] is still uninitialized... May be you mean, you are trying to... gsi[i] = ISBN[i] ; Similar for all.. Edit : oh... On!oN You declared int Arrays.. But trying with charecter manipulations... And some More errors there...
31st Jul 2020, 3:47 PM
Jayakrishna 🇮🇳
+ 1
you have warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int (*)[13]' [-Wformat=] 17 | scanf("%d",&ISBN); | ~^ ~~~~~ | | | | | int (*)[13] | int * same is true for all your warnings check this page to learn more how to check ISBN if you need: https://www.geeksforgeeks.org/program-check-isbn/
31st Jul 2020, 3:59 PM
Coder
Coder - avatar
+ 1
On!oN did you fix your code yet? I gave working code in my answer. I see the original broken version in your link to this question.
5th Aug 2020, 12:58 PM
Josh Greig
Josh Greig - avatar
0
Jayakrishna🇮🇳 yeah😬 i trying that but when I'm printing ISBN value why that shows garbage value
31st Jul 2020, 3:50 PM
Samarendra Singh
Samarendra Singh - avatar
0
Josh Greig yes i did that Thanks alot😊
5th Aug 2020, 4:18 PM
Samarendra Singh
Samarendra Singh - avatar