   Absolute Beginner to C - Q's
  Now back to focus on the present where I find 20 more new terms I don't know about, when I'm trying to understand one term... thats how noob I am. you can understand how much of an Absolute beginner in C I am in my previous topoc [Student -> Game Industry]So I'm learning to learn C from Greg Perry and I have a couple of questions for you guys.  Any advice given is very appreciated.Chapter 1: First Steps with C. -What is a program? I comprehend this one. program being to a computer what a recipe is to a cook. but more specific programs need to be compiled into binary so that the computer can read it and execute it. So it becomes software for hardware.-What you NEED to write C programs. A C compiler: Borland C++ and Visual C++ is more advanced then Turbo C++ it says. But does it mean that Turbo C++ is more easy to begin with? I use Windows by the way, do I need something else then windows or will windows do fine now that I'm such a beginner, I'll figure those stuff out later?-The Programming ProcessCreate and edit text with editor and save those programming language instructions. Is that saved instructions now called a Program? I don't get that. So the text I wrote in programming language and then saved, is a .C file extension? or should it be? and is Notepad an editor? Or do I need to use the editors from Visual C++ 2005 I just installed where ever I can find those?-Using CI need to stay with ANSI C commands instead of using compiler-specific C functions that might not be available in other compilsers I will use later. I don't rly need to worry about stuff like this right? I don't even know the American National Standards Institutes rules for C that makes the program standard or whatever... Guess Greg Perry doesn't want me to start of programming with bad habbits that might limit me later on? Same stuff I had to learn when playing guitar.So now after these stuff in the book I have to "Type a program" using my C compiler's editor (which I can't even find anywhere, all I find is projects and files), compile the program, and run it. I think I tried this already in the past but I failed not knowing where to find the compile command of C++ software. The windows of Visual C++ is always jam packed with terms I don't understand at all. So I always go with hunches but this is all guess work. I do have experience with word processors or painting software, so I open Visual C++ 2005 express edition now. I come across a window called Start Page - Visual C++ 2005 express edition. I then click on "File" then I can choose "Project(ctrl+shift+N)" or "File(ctrl+N)" . When I choose project then I come across a new window jam packed with terms I don't understand. So I open File.I come across a window with Catogories: General/Visual C++/ScriptI'm on general and I finally see a familiar word under Templates (templates??) called: Text File. So that is the new file I open, because I remember I had to write a TEXT  in programming language before it can become a .C extension program. But when I do write stuff here in the TEXT FILE:/* Prints a message on the screen */# include <studio.h>main(){Printf("This C stuff is easy!\n");return 0;}How can I save this in .C extension? I can only save is as .txt in my "projects" documents. The book doesn't cover these stuff at all. I'm stuck here.So then I tried to compile what I wrote there anyway, but I can't find the compile command anywhere in visual C++.Any advice given is very appreciatedThanks in advance   
  There are a couple of errors in your program./* no space between # and include, and it's not studio but stdio */#include <stdio.h>/* the return type of main is int and MUST be written down in ANSI C   the void inside the paranthesis is not needed but recommended */int main(void){/* printf is written with a lowercase p */printf("This C stuff is easy!\n");/* You don't need the return 0; in ANSI C*/}As for Visual C++, you need to create a Project first. Did you do that?   ;Quote:As for Visual C++, you need to create a Project first. Did you do that?Indeed. You can create a new project, twintwix, from the File -> New Project menu option in Visual Studio. If you're having trouble navigating the resulting dialogs or ending up with a project that already has a bunch of strange looking automatically generated code, you might want to read this recent blog post aboutcreating a blank C++ project in Visual Studio.   ;Quote:Original post by twintwix-What you NEED to write C programs. A C compiler: Borland C++ and Visual C++ is more advanced then Turbo C++ it says. But does it mean that Turbo C++ is more easy to begin with? I use Windows by the way, do I need something else then windows or will windows do fine now that I'm such a beginner, I'll figure those stuff out later?I wouldn't use either Borland C++ or Turbo C++, personally. If you are programming on Windows use either Code::Blocks or the latest version of Visual C++ Express Edition (2008) as your IDE. Neither are *that* complex to set up, although Visual C++ is probably a little more difficult than Code::Blocks for a beginner.Quote:-The Programming ProcessCreate and edit text with editor and save those programming language instructions. Is that saved instructions now called a Program? I don't get that. So the text I wrote in programming language and then saved, is a .C file extension? or should it be? and is Notepad an editor? Or do I need to use the editors from Visual C++ 2005 I just installed where ever I can find those?The 'saved instructions' the author is referring to are probably what is more generally called 'source code'. It is the textual representation of your program before it is compiled into an executable file.Any program that can edit text files can be used as a source code editor. That includes Notepad. Some people prefer no bells or whistles when programming, but most like to have ways to help with programming. This goes from syntax highlighting and showing line numbers all the way up to integrated software debugging from remote locations. All of that functionality is included with the "IDE".Quote:summary: how do I create a project, compile my program, and run it with Visual C++?I have Visual C++ Express Edition 2008 installed, but the steps are very similar. I'll just give a quick step-by-step list of instructions.1)Create a project by clicking "File -> New -> Project" then select "Visual C++ -> Win32 -> Console Application" then type in a name for your project in the text box provided and click 'OK'. In the Win32 Application Wizard on the left side of the window select "application settings" and under "additional options" check the "empty project" box and click "finish"2)Add source code to project. On the left of Visual C++, you'll see something called the "Solution Explorer". This will show the project name and three folders (called Filters in Visual C++) under the project including "source files". Right click "source files" and select "add -> new item". In the window that pops up select "Visual C++ -> Code -> C++ File (.cpp)". You want a .C file, but that's alright you can just name it whatever.c and it will have that extension and not whatever.cpp. Click "add".3)Edit default settings (Microsoft allows developers to choose between using Unicode versions of their library and ASCII versions of their library setting where they set the default to Unicode. Most books use ASCII versions of libraries so we will change the default to ASCII (called multi-byte in Visual C++). To do so, click "Project -> <your project name> properties" then select "configuration properties -> General -> character set -> use multi-byte character set" and click "ok". If you don't do this then you will probably get a few errors when compiling that will probably seem confusing.4)Edit the source code in whatever.c.5)Compile and run your program. There are several ways to do this, but perhaps the easiest is to hit F5 as that will compile the program if it the executable is out of date or non-existent and then run the program. *However* the window that will pop up will almost certainly open and then immediately close. This is the normal behavior for console (ie, text only) programs in Windows, but it doesn't do you a lot of good to see your program dissapear before you see anything. So instead, you can hit Ctrl + F5 which will add a 'pause' at the end of your program automatically.OR alternatively to all that you can instead drop C and learn Python or C# instead, unless you have a compelling reason to learn C specifically. Or at least C++ instead of C. But that's not your question so whatever.Hope this helps.edit: *bookmarks that jpetrie link*   ;Quote:Original post by twintwix-What you NEED to write C programs. A C compiler: Borland C++ and Visual C++ is more advanced then Turbo C++ it says. But does it mean that Turbo C++ is more easy to begin with? I use Windows by the way, do I need something else then windows or will windows do fine now that I'm such a beginner, I'll figure those stuff out later?1) "Advanced" and "easy (to use)" have nothing to do with each other. They're not the same; but they're not opposites either.2) Of course Windows is fine. It's fine for advanced users, too. Your operating system has no more effect on your ability to program than an artist's apron has on the artist's ability to paint.Quote:Create and edit text with editor and save those programming language instructions. Is that saved instructions now called a Program?People could debate minor points about it, but that's pretty much it.Quote:I don't get that. So the text I wrote in programming language and then saved, is a .C file extension? or should it be?The file name should have a .c file extension, yes. And I'm picking at your choice of words here for the reason that being precise is important for programmers. The computer can't understand you on a human level.Quote:and is Notepad an editor?Yes. You can use pretty much anything to write the program.Quote:Or do I need to use the editors from Visual C++ 2005 I just installed where ever I can find those?They are built right into the main program. Visual C++ may put several .exe's on your hard drive, but you don't need to try to hunt them down and use them separately. The whole point of Visual C++ is that it makes those .exe's talk to each other for you. Hence, Integrated Development Environment.Quote:I need to stay with ANSI C commands instead of using compiler-specific C functions that might not be available in other compilsers I will use later. I don't rly need to worry about stuff like this right?No, you really should worry about these things. However, the author will do most of the worrying for you. All you really have to do is not go out of your way to look something up and also ignore warnings about it being compiler-specific. :)Quote:So now after these stuff in the book I have to "Type a program" using my C compiler's editor (which I can't even find anywhere, all I find is projects and files),Visual C++ is not a compiler; it is an IDE. No compiler "has an editor"; editing the program (creating the source file) is a separate task from compiling it. But "the editor" for Visual C++ would be the main panel that you can type text into.Quote:The windows of Visual C++ is always jam packed with terms I don't understand at all.Tools designed for programmers are not designed to teach you anything about programming. They're designed with the assumption that you're already a programmer.You don't have to use an IDE. You can get compilers on their own, without an IDE, too.Quote:I come across a window called Start Page - Visual C++ 2005 express edition. I then click on "File" then I can choose "Project(ctrl+shift+N)" or "File(ctrl+N)" . When I choose project then I come across a new window jam packed with terms I don't understand. So I open File.This is Microsoft's confused attempt at trying to make a programmer's tool user-friendly, yeah.Quote:I come across a window with Catogories: General/Visual C++/ScriptI'm on general and I finally see a familiar word under Templates (templates??)Oh, come on. "template" is a perfectly normal English word. :)It seems that your default response to seeing information you don't understand is to freeze up and back away from it. This is a Big Problem if you want to be a programmer.Taking a look through the "Help" menu and trying to get it to tell you something useful is a much better instinct.Quote:How can I save this in .C extension?The same way you specify a file extension for any other file that you save: by typing it (replacing any extension that's already supplied).Quote:I can only save is as .txt in my "projects" documents.No; that's only the extension that they suggested for a default. And the reason they suggested it is because "text files" normally have a .txt extension.I want you to try the following:1) Open Paint.2) Hit "Save As...".3) Make a note of the extension of the file name that is suggested to you. (The file name will be something like "Untitled.jpg"; so in that case you would remember that it suggested "jpg".) Replace the entire suggested file name with "picture.txt".4) Save the file. It should save with the usual icon for .txt files.5) Double-click it. It should open in Notepad (unless you set it to use something else for .txt files), and look like a bunch of gibberish. This is the data that makes up the image, reinterpreted as text.6) If the icon for the file in Windows doesn't actually show the .txt extension (i.e. you just see the icon and "picture"), enable display of file extensions (go to the Folder Options control panel, and in the "Advanced settings:" panel on the "View" tab, uncheck "Hide extensions for known file types").7) Rename the file. Select the "txt" part of the name and change it to the original file extension.8) Now it's a (blank) picture again.Quote:The book doesn't cover these stuff at all. I'm stuck here.Because these tasks are nothing to do with the actual task of programming.Quote:So then I tried to compile what I wrote there anyway, but I can't find the compile command anywhere in visual C++.Once you have a project set up, it should appear. :)   ;  Just to answer a question that Zahlman didn't really cover very well, as far as notepad is concerned, you can make a lot of things with it.  You can write any web related code with it, as well as any programming related source code with it.  The reason is, notepad is considered a text editor.  Text editors and word processors are two different things, which is why you shouldn't use programs like Wordpad or Microsoft Word to write your .C source files.  Reason is, those programs are word processors.  What that means, is it adds formatting to your text, which allows you to use different fonts, headings, sizes, etc.  If you were to save a file in notepad after changing the font, character strength(bold), emphasis(italics), etc, and try to load it on a different computer (say a stock Windows XP setup), you are going to get whatever settings that they have for their copy of notepad.  If you take a .doc or .docx (Wordpad or M.Word 2007) on a different computer, it will display using whatever you set them to (unless of course that computer doesn't have the fonts specified). Does that make any sense?If they IDE you are using isn't making much sense to you, perhaps it would be easier to lookup a standalone compiler and just use notepad.If you decide to stick with Microsoft Visual C++, update.  The 2005 version is outdated, and doesn't follow the updated ANSI standards that you SHOULD be reading.  C probably isn't the greatest starting point for you either.  You should look into languages such as C# or Python.   ;Quote:Original post by DevFredThere are a couple of errors in your program./* no space between # and include, and it's not studio but stdio */#include <stdio.h>/* the return type of main is int and MUST be written down in ANSI C   the void inside the paranthesis is not needed but recommended */int main(void){/* printf is written with a lowercase p */printf("This C stuff is easy!\n");/* You don't need the return 0; in ANSI C*/}As for Visual C++, you need to create a Project first. Did you do that?Wasn't sure, it relax me alot more now that someone can confirm it ^^ So I was doing the right thing now its less guess work for me ;P And ty for correcting those, you just helped me with my first debugging ever hehe, I think they were typo's.   ;Quote:Original post by jpetrieQuote:As for Visual C++, you need to create a Project first. Did you do that?Indeed. You can create a new project, twintwix, from the File -> New Project menu option in Visual Studio. If you're having trouble navigating the resulting dialogs or ending up with a project that already has a bunch of strange looking automatically generated code, you might want to read this recent blog post aboutcreating a blank C++ project in Visual Studio.Cool, ty, I've saved that link in notepad, will look into that.   ;Quote:Original post by nobodynewsI wouldn't use either Borland C++ or Turbo C++, personally....  .......helps.edit: *bookmarks that jpetrie link*Wow,  I've saved those step by step instructions on notepad, will check m out tomorrow, getting late. And I've also heard about Python on my previous topic, I said that as Greg Perry was treating its audience in "Absolute beginners guide to C" as if they were old people who never touched a computer, I thought that it was beginner friendly xD I'm checking out Python for sure, its been suggested the second time, this time by you. Ty alot, nobodynews,  you were very helpful :-)   ;  Typically you will find that in programming books, they mean people who are new to programming, not people who are new to computers in general.   