![]() |
|
[C] 'cin' Isn't working - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] 'cin' Isn't working (/showthread.php?tid=5694373) |
'cin' Isn't working - JAS - Aug 14, 2017 Code // sa.cpp : Defines the entry point for the console application.please what am i doing wrong here? * - CortexM4 - Aug 14, 2017 I know this is a troll but just in case it is not. Code int hello;* - JAS - Aug 14, 2017 (Aug 14, 2017 08:43 AM)CortexM4 Wrote: I know this is a troll but just in case it is not. Not a troll. I just started today and im taking it pretty seriously and not leaving anything out. I got like 3 books from my library lmao * - Fυcĸleѕѕ - Aug 14, 2017 I also started learning C++ today. Found a recent free tutorial that is pretty good so far: -snip- EDIT: I guess the site is considered Warez. How dated are the books you're using? * - JAS - Aug 14, 2017 (Aug 14, 2017 08:48 AM)Fυcĸleѕѕ Wrote: I also started learning C++ today. Found a recent tutorial that is pretty good so far: I dont know. There from a libary so probulary pretty old 2011.... :/ is that ok? * - CortexM4 - Aug 14, 2017 I would suggest learning C first. Heres the classic one: https://github.com/germanoa/compiladores/blob/master/doc/ebook/The%20C%20Programming%20Language%20-%202nd%20Edition%20-%20Ritchie%20Kernighan.pdf Proper ebook version: http://yunus.hacettepe.edu.tr/~yurdugul/3/C/c.pdf Once you learn C you will know how memory works and how to work with it, only then focus on C++ and all of it's advanced features. I also suggest you read this in parallel, it helps understanding the underlying architecture and how your code ends up executing on a computer. http://joe90.yolasite.com/resources/InsidetheMachine.pdf C++ is quite massive for a total beginner. * - 0xDEAD10CC - Aug 14, 2017 How about reading the compiler warnings as a start? I'm pretty sure the error message for this one should be self-explanatory and won't be 100 lines like some other C++ errors. * - Hapi - Aug 14, 2017 You might want to try initialise a variable before you try to use it. Keep learning because getting input for Strings is different than with numbers. * - 0xDEAD10CC - Aug 14, 2017 (Aug 14, 2017 04:51 PM)Looka Wrote: You might want to try initialise a variable before you try to use it. Keep learning because getting input for Strings is different than with numbers. It can be the same in terms of how input streams work and std::basic_string<char> (std::string). There's a limitation, but if it doesn't matter with the string value requirements, then you wouldn't be able to tell much of a difference. * - JAS - Aug 15, 2017 (Aug 14, 2017 04:51 PM)Looka Wrote: You might want to try initialise a variable before you try to use it. Keep learning because getting input for Strings is different than with numbers.Louka is that you? * - Zens - Aug 15, 2017 Code #include <iostream>declared the the 'hello' first. Cheers * - Flaws. - Aug 15, 2017 (Aug 15, 2017 07:38 AM)zenzuk0 Wrote: Exactly what this user said, you need to declare the integer first and then assign a value to it using cin * - 0xDEAD10CC - Aug 15, 2017 (Aug 15, 2017 07:38 AM)zenzuk0 Wrote: ... Why global?... Code #include "stdafx.h"* - CortexM4 - Aug 15, 2017 (Aug 15, 2017 09:17 AM)0xDEAD10CC Wrote: Why global?...In his defense, it's just an example, I'm sure that if OP put some time in to it he would learn proper programming practices. * - 0xDEAD10CC - Aug 15, 2017 (Aug 15, 2017 09:31 AM)CortexM4 Wrote: In his defense, it's just an example, I'm sure that if OP put some time in to it he would learn proper programming practices. It's just as easy to provide him with good programming practices instead of assuming he will understand that what you're giving him isn't the best way to do things. Same amount of code, different scope/line. |