LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2016, 09:39 PM   #16
Myk267
Member
 
Registered: Apr 2012
Location: California
Posts: 422
Blog Entries: 16

Rep: Reputation: Disabled

Quote:
Originally Posted by dugan View Post
Did that work?
Did you paste the old text in instead of the fixed version?
 
Old 03-12-2016, 01:22 AM   #17
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by dugan View Post
Try this:
C++ is not the best language for a beginner to start off with (try Java or Python if you must learn an OOP). And if you want to learn about character arrays, a string object isn't the most educational way to do it.

You could always use your original example but use <stdio.h> functions rather than <iostream> functions.
Code:
$ cat ask.c
#include <stdio.h>

int main () {
   char ask[]= "Enter your first name: ";
   char answer[]= "So your name is ";
   char name[100];

   printf("%s", ask);
   scanf("%s", name);
   printf("%s%s.\n",answer,name);
}
$ gcc -o ask ask.c
$ ./ask
Enter your first name: Johnny
So your name is Johnny.
$

Last edited by psionl0; 03-12-2016 at 01:23 AM.
 
Old 03-12-2016, 03:10 AM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,831

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Unfortunately gcc has 2 different meanings, which is quite annoying. First: gcc stands for gnu compiler collection and (how to say) it is (more or less) a language-independent engine (to make executables from source code).
Furthemore gcc itself is one of the tools within gcc, the compiler collection, especially that is the gnu version of the good old c compiler.
If you want to use gcc (the compiler collection) you need to install the engine itself - which are the linker, the preprocessor, debugger among the lot of other goodies) and the language specific toolset too (like c, c++, fortran ... and/or whatever compiler you need).
The name of the c++ compiler is g++
 
Old 03-12-2016, 06:17 PM   #19
FortuneTeller5000
LQ Newbie
 
Registered: Mar 2016
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Unfortunately gcc has 2 different meanings, which is quite annoying. First: gcc stands for gnu compiler collection and (how to say) it is (more or less) a language-independent engine (to make executables from source code).
Furthemore gcc itself is one of the tools within gcc, the compiler collection, especially that is the gnu version of the good old c compiler.
If you want to use gcc (the compiler collection) you need to install the engine itself - which are the linker, the preprocessor, debugger among the lot of other goodies) and the language specific toolset too (like c, c++, fortran ... and/or whatever compiler you need).
The name of the c++ compiler is g++
yeah im pretty sure that all came with installing code::blocks, but i'm also curious about how people would use gedit and notepad and then just compile code straight from that
 
Old 03-12-2016, 06:33 PM   #20
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by FortuneTeller5000 View Post
yeah im pretty sure that all came with installing code::blocks, but i'm also curious about how people would use gedit and notepad and then just compile code straight from that
What do you mean how? The same way you've done at the start of this thread, except without mixing C and C++. If you want to use iostream, cin, cout, etc., that's C++, which means your code should end in .cpp and you should compile it with g++. If you want to use C, then the code should end in .c and you should use printf, etc.
 
Old 03-13-2016, 01:43 AM   #21
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,831

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
in general gedit and notepad are not really used to write code, there are much better editors available exactly for that. Using one of those editors you will be able to "just compile code straight from that". Those are: vi (or vim), emacs, eclipse and a huge amount of other tools. They called IDE. (in MS Windows there is an editor called notepad++ which is also very good, because that is much more than a simple notepad).
So return back to your question: developers do not use gedit or notepad, but you can start using those and also write a makefile to compile and build your code.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] iostream.h exists, yet facing "iostream.h: No such file or directory" mq15 Linux - Software 13 01-02-2010 09:13 AM
Linux iostream vs Windows iostream davidguygc Programming 2 05-13-2007 09:13 PM
What the hell happened to my Gnome?? valdiorn Linux - Software 6 08-08-2005 06:05 PM
What the hell just happened? crnchyfrog Mandriva 1 05-30-2005 03:31 AM
What the hell happened?!?!?!? TheRealDeal Linux - General 2 09-20-2003 07:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration