LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2004, 08:45 AM   #1
jitus
LQ Newbie
 
Registered: Mar 2004
Location: Mumbai(Bombay)
Distribution: Red Hat 8
Posts: 20

Rep: Reputation: 0
Question C++: Compling -- It works; Running ???


Before stating my problem. let me describe what i've done.

i wrote the simple c++ prog. in vi editor:

Code:
// myprog.cpp

#include<iostream>
using namespace std;

int main()
{
     int a,b;
     cout<<"Enter a";
      cin>>a;
      cout<<"Enter b";
      cin>>b;
       cout<<"Addition is:"<<a+b;
       return 0;
}
then i compiled the prog.

# g++ -o myprog myprog.cpp

It didn't show me any error.

When i tried to execute it.

#./myprog

It give o/p:

Enter a

When I entered some no. It took me to shell prompt.

Where has rest of my code gone?
When I tried to run other small prog, same thing happened, means, only first line of the prog. got executed.


Plz help me
 
Old 03-22-2004, 10:20 AM   #2
Tap-Out
Member
 
Registered: Oct 2002
Location: Halifax, NS
Distribution: Ubuntu, Mepis, Debian
Posts: 130

Rep: Reputation: 15
I wrote out your code, line for line, word for word, followed the exact same steps you did and I had no problems?? I don't know why you're getting errors.
 
Old 03-22-2004, 10:22 AM   #3
jalal
Member
 
Registered: Aug 2003
Location: .bh
Distribution: Gentoo
Posts: 188

Rep: Reputation: 30
hmm... works for me. Does C work for you ? or is it only with C++?
 
Old 03-23-2004, 07:31 AM   #4
jitus
LQ Newbie
 
Registered: Mar 2004
Location: Mumbai(Bombay)
Distribution: Red Hat 8
Posts: 20

Original Poster
Rep: Reputation: 0
hi jalal,

same thing happens with C also.
 
Old 03-23-2004, 09:43 AM   #5
jalal
Member
 
Registered: Aug 2003
Location: .bh
Distribution: Gentoo
Posts: 188

Rep: Reputation: 30
Maybe you have a corrupted install or a bad version. try upgrading your gcc, glibc, ... and see if that helps.
 
Old 03-23-2004, 10:15 AM   #6
jitus
LQ Newbie
 
Registered: Mar 2004
Location: Mumbai(Bombay)
Distribution: Red Hat 8
Posts: 20

Original Poster
Rep: Reputation: 0
hello jalal & everyone out there,

There is one more package in Red Hat 8 called 'debugger' or something like that. when i used that one, programme runs OK.

It is giving problem with vi editor.

What could be the reason?
 
Old 03-23-2004, 01:30 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Were you doing all of the above within a
shell in vi? In this case maybe vi doesn't
pass keystrokes on properly to the processes
you're running from within.


Cheers,
Tink
 
Old 03-23-2004, 03:15 PM   #8
legend1079
Member
 
Registered: Mar 2004
Location: Pakistan
Posts: 49

Rep: Reputation: 15
ahy
sorry for asking
but wats the
vi
....
??
 
Old 03-23-2004, 03:53 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
sorry for asking
but wats the
vi
A cryptic abomination of a text editor :}


Cheers,
Tink
 
Old 03-23-2004, 04:31 PM   #10
cadkins
Member
 
Registered: Mar 2004
Location: <----- there
Distribution: Mandrake 9.0 - 9.2, Slackware 9.1 - 10
Posts: 98

Rep: Reputation: 15
Quote:
A cryptic abomination of a text editor :}
haha! Glad someone else feels that way. I was beginning to think I was the only one

I like using Kate for command line stuff like this. Has worked well for me so far. Has one section for the code and the command prompt underneath. Handy
 
Old 03-23-2004, 07:18 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by cadkins
I like using Kate for command line stuff like this. Has worked well for me so far. Has one section for the code and the command prompt underneath. Handy
Kate is kind of cute, but she looses lots of her charme
over a slow modem line ;)

Emacs, baby!


Cheers,
Tink
 
Old 03-24-2004, 08:33 AM   #12
cadkins
Member
 
Registered: Mar 2004
Location: <----- there
Distribution: Mandrake 9.0 - 9.2, Slackware 9.1 - 10
Posts: 98

Rep: Reputation: 15
Quote:
Originally posted by Tinkster
[B]Kate is kind of cute, but she looses lots of her charme
over a slow modem line

Emacs, baby!
haha. yeah....Kate is kind of cute.

I love Emacs though. It's my default for when I need to view something like a config file or something... I think it's the groovy green
 
Old 03-24-2004, 10:04 AM   #13
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
I always figured the only people who hated vi were those not bright enough to use it
 
Old 03-24-2004, 11:56 AM   #14
cadkins
Member
 
Registered: Mar 2004
Location: <----- there
Distribution: Mandrake 9.0 - 9.2, Slackware 9.1 - 10
Posts: 98

Rep: Reputation: 15
Quote:
Originally posted by Komakino
I always figured the only people who hated vi were those not bright enough to use it
yeah yeah...
 
Old 03-24-2004, 01:02 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by Komakino
I always figured the only people who hated vi were those not bright enough to use it :D
Man, those vi users ... can't even get the simplest statements right O;)

It's
I always figured the only people who hated vi were those bright enough not to use it :D


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Running the bash with email and the works Dralnu Linux - Software 5 08-15-2005 05:24 PM
Linspire 5 (Won't install) But when running off CD works fine? Linoman Linspire/Freespire 5 05-20-2005 04:16 AM
Sound works only when I am running as root. njbrain Linux - Hardware 6 03-29-2004 11:44 AM
Running quake2 as user (so far, only works as root) glock19 Linux - Games 5 03-08-2004 11:07 AM
compling c++ LinuxTiro Programming 16 08-30-2003 06:04 AM


All times are GMT -5. The time now is 02:40 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration