Re: C input?

All this pointer stuff and stack stuff is probably confusing. As people have already mentioned, C is different enough from Python, _javascript_, etc, to have to endure a steep learning curve, especially if you're accustomed to dealing with higher level languages. I haven't really tested out your code, but I think this code essentially has the problem of function scope and the dreaded pointer management problem. Pointers are very tricky, and others have already done a good job explaining some of the intricate details. As an experiment, try directly printing the output variable as populated by the call to scanf after your failure condition in your getIntInput function. In other words, try printf(a) in that function. Additionally, I'm not sure you can return NULL in a function with the defined int return type. There is also the issue of scope, which I briefly mentioned. I'm not sure that a populated memory address is retained when the function exits. In other words, this relates back to the stack which others have explained. My recommendation would be to pass a temp variable to the function that calls the scanf function. I think this will allow the value to be retained for your comparisons in the main function. These are some suggestions as I can't really type a more an-depth explanation at the moment.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : mechaSkyGuardian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : gonzalez via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : thggamer via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kaigoku via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : leibylucw via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kaigoku via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kaigoku via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to