C++ Newbies Question

is prob something Simple

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

32 Replies - 2187 Views - Last Post: 07 June 2010 - 05:07 PM Rate Topic: -----

#16 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Re: C++ Newbies Question

Posted 06 June 2010 - 12:57 AM

Another way to do this is to request input from the user and once the user has entered input to close the window via one of windows system commands, this will work if you are using windows, simply add the following to your program after cout << "Hello World";
 char response;
 std::cin >> response;
 system("EXIT");



I am assuming however you have windows as you have said that this is your favourite Operating System.
Hope it Helps otherwise use one of the other ways given, all should work.
Remember to #include <iostream> or the standard library (std) will not be found and thus you will get an error.

This post has been edited by v0rtex: 06 June 2010 - 12:58 AM

Was This Post Helpful? 0
  • +
  • -

#17 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 02:44 AM

Ok, thanks
i have a do-while loop,
it all works perfect now thanks
Also i said
#include <mysql.h>

But its not found, Then i look through some folders and finde sql.
so i say
#include <sql>

and there are 51 errors on it, so what do i do, because i want to do some database projects.
I have lots of exp with SQL,and MYSQL

Thanks aaron1178
Was This Post Helpful? 0
  • +
  • -

#18 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: C++ Newbies Question

Posted 06 June 2010 - 02:51 AM

Read and enjoy
http://dev.mysql.com...nector-cpp.html
Was This Post Helpful? 0
  • +
  • -

#19 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 03:46 AM

ok that really doest help, ive put aqll the libs in there right spot but how do i call it like do i use mysql_connect()
Was This Post Helpful? 0
  • +
  • -

#20 Guest_Matthew*


Reputation:

Re: C++ Newbies Question

Posted 06 June 2010 - 09:39 AM

View Postaaron1178, on 04 June 2010 - 10:26 PM, said:

Hey all,
I am new as in just stated just then and im following a tutorial,
im using c++ builder and im making a console app.
I have this code in it:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World";
return 0;
}

i then click run and i compiles it and then opens a console for about 5 seconds but then goes away,
i am new and have no exp with it,
Could you please tell me whats wrong
Thanks Aaron1178

try pressing ctrl+f5
see if that will do anything
Was This Post Helpful? 0

#21 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: C++ Newbies Question

Posted 06 June 2010 - 11:57 AM

Matthew, his original question was already answered. Did you read the entire topic?
Was This Post Helpful? 0
  • +
  • -

#22 C++ Programmer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 20
  • View blog
  • Posts: 548
  • Joined: 12-June 08

Re: C++ Newbies Question

Posted 06 June 2010 - 01:34 PM

Apparently not.
Was This Post Helpful? 0
  • +
  • -

#23 At0m1k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-June 10

Re: C++ Newbies Question

Posted 06 June 2010 - 02:44 PM

View Postrunnerrob, on 05 June 2010 - 09:24 AM, said:

Would it be of any use to insert this line

system ("pause");

before you end you're program with

return 0;

The program will ask to press any key to continue.


It's not wise to use systems calls, cin.get(); will suffice.
Was This Post Helpful? 0
  • +
  • -

#24 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 04:18 PM

Ok thanks for all your help,
its going good now, but i have anothe question.

Im Developing(Trying my hardest) to develop a console client for a website.
I want it to be a database type app were you can type "/connect" and it wil run the mysql_connect thing, but my question is,
should i use sockets or mysql?

Thanks Aaron1178
Was This Post Helpful? 0
  • +
  • -

#25 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,436
  • Joined: 23-August 08

Re: C++ Newbies Question

Posted 06 June 2010 - 05:23 PM

Just to introduce a little dose of reality...if you just started learning C/C++ to the extent that you're following a tutorial on a Hello World program, I'm going to venture to say you're not NEARLY ready to tackle sockets OR MySQL. PHP may be somewhat forgiving, but C/C++ are most definitely NOT.
Was This Post Helpful? 0
  • +
  • -

#26 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 08:54 PM

Hey, thanks, i do get ur point but, i seem to have adepted to c++.
I will read a few tutorials ad post my work, i reckon that even though i WANT to takle this task, i know its a blow to u, "Yeah this kid wants the impossible", but thanks fo the heads up.

But, know one has answered my question, witch is better, mysql or sockets.

Thanks Aaron1178
Was This Post Helpful? -1
  • +
  • -

#27 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 09:26 PM

DELETE, internet done this, it timed out :)

This post has been edited by aaron1178: 06 June 2010 - 09:27 PM

Was This Post Helpful? 0
  • +
  • -

#28 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: C++ Newbies Question

Posted 06 June 2010 - 11:29 PM

SORRY THE INTERNET LOL - PLEASE DELETE

This post has been edited by aaron1178: 06 June 2010 - 11:30 PM

Was This Post Helpful? -1
  • +
  • -

#29 Guest_Adem*


Reputation:

Re: C++ Newbies Question

Posted 06 June 2010 - 11:52 PM

View Postaaron1178, on 04 June 2010 - 10:26 PM, said:

Hey all,
I am new as in just stated just then and im following a tutorial,
im using c++ builder and im making a console app.
I have this code in it:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World";
return 0;
}

i then click run and i compiles it and then opens a console for about 5 seconds but then goes away,
i am new and have no exp with it,
Could you please tell me whats wrong
Thanks Aaron1178


Hi Aaron,

do you have a separate .exe after compiling the sourcecode? If yes, try to run it by opening cmd first and typing in the name of your executable. Ask here if you don't know how to use cmd.

Another solution is to add the following code which is waiting for a keypress after the program is finished. This prevents cmd to close too fast.

cin.get();

Was This Post Helpful? 0

#30 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: C++ Newbies Question

Posted 06 June 2010 - 11:56 PM

View Postaaron1178, on 07 June 2010 - 12:54 PM, said:

witch is better, mysql or sockets.


Answer this:
Which is better, wood or steel?
You can't answer that usefully unless you know:
- what I want to use them for
- what I already know how to use
- what I can afford
- lots of other things

That's why no-one is answering the question.
As you asked it, it is impossible to answer in a meaningful way.

Since you are in the beginner's phase both are going to be a huge stretch for you to get working so just choose one and see how far you get.

Like JackOfAllTrades I think you would be better off working through a 'learn to' book before you try this stuff because you simply don't know enough to understand the tutorials etc that will be presented to you. You will probably need to put the foundations in place first before you can move onto these kind of things.

Good luck regardless.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3