My little "Hello World"

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Re: My little "Hello World"

Post by iistapp on Thu May 24, 2012 2:14 am
([msg=66574]see Re: My little "Hello World"[/msg])

LoGiCaL__ wrote:
Try this:

Code: Select all
@ECHO OFF
color A
echo TITLE
pause
cls
cd/
tree
tree /f


The issue in your batch file is that you need to make it go to the root of c: before you run the tree command. You could also write the output of tree to a file within the current directory you run the batch file in.

Code: Select all
tree >> output.txt


Cheers, forgot the pause command... Anywho! ended up with this.

Code: Select all
@echo off
color 2
title test
cls
cd/
tree
tree /F
pause


Well, that was easy, but still a start. But still not exactly in the direction I wanted to go.

I would like to thank everyone tho. Been of great help and information.

I guess I'll have to try making something like a text based game of some sort once I figure what to go for when it comes to a language.

Would this be suggested to start off from the start, or should I get something that already is made and improve it?
User avatar
iistapp
Poster
Poster
 
Posts: 130
Joined: Tue Apr 21, 2009 9:44 am
Location: Norway
Blog: View Blog (0)


Re: My little "Hello World"

Post by LoGiCaL__ on Thu May 24, 2012 11:47 am
([msg=66582]see Re: My little "Hello World"[/msg])

iistapp wrote:I guess I'll have to try making something like a text based game of some sort once I figure what to go for when it comes to a language.

Would this be suggested to start off from the start, or should I get something that already is made and improve it?


It probably varies person to person. I would start of coding something from scratch as I believe it's easier to write your own code then to read someone else's when starting out. Plus you start to embed the template/structure you will be using from there on out in your head. I would start off with a text game or even a high/low number guessing game. That is if you already know the basic syntax of the language already.
User avatar
LoGiCaL__
Moderator
Moderator
 
Posts: 1048
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: My little "Hello World"

Post by iistapp on Sat May 26, 2012 8:41 am
([msg=66614]see Re: My little "Hello World"[/msg])

LoGiCaL__ wrote:
It probably varies person to person. I would start of coding something from scratch as I believe it's easier to write your own code then to read someone else's when starting out. Plus you start to embed the template/structure you will be using from there on out in your head. I would start off with a text game or even a high/low number guessing game. That is if you already know the basic syntax of the language already.


Meaning I'll have to do some reading to learn the basic syntax of the language?

The problem is I need to just write some code to learn, as reading it over and over in my head won't do me much other than giving up of boredom.

Would you suggest Dev-C++ to write C/C++ in?
User avatar
iistapp
Poster
Poster
 
Posts: 130
Joined: Tue Apr 21, 2009 9:44 am
Location: Norway
Blog: View Blog (0)


Re: My little "Hello World"

Post by LoGiCaL__ on Sat May 26, 2012 1:33 pm
([msg=66615]see Re: My little "Hello World"[/msg])

iistapp wrote:
LoGiCaL__ wrote:
It probably varies person to person. I would start of coding something from scratch as I believe it's easier to write your own code then to read someone else's when starting out. Plus you start to embed the template/structure you will be using from there on out in your head. I would start off with a text game or even a high/low number guessing game. That is if you already know the basic syntax of the language already.


Meaning I'll have to do some reading to learn the basic syntax of the language?

The problem is I need to just write some code to learn, as reading it over and over in my head won't do me much other than giving up of boredom.

Would you suggest Dev-C++ to write C/C++ in?


You obviously have to write the code after learning the concept otherwise it won't stick. I like to take it in parts. If there is something I don't understand I keep at it until it makes sense and I can implement it on my own. As for your question about Dev-C++, I can't give you an answer to that as I have never used Dev-C++ . I just write my code in the nano text editor and compile with gcc .
User avatar
LoGiCaL__
Moderator
Moderator
 
Posts: 1048
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: My little "Hello World"

Post by ghost107 on Sat May 26, 2012 1:54 pm
([msg=66617]see Re: My little "Hello World"[/msg])

iistapp wrote:Would you suggest Dev-C++ to write C/C++ in?

Dev-c++ is a good IDE for for low resource windows based systems.
http://www.bloodshed.net/dev/devcpp.html
ghost107
Poster
Poster
 
Posts: 110
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: My little "Hello World"

Post by iistapp on Sat May 26, 2012 11:08 pm
([msg=66621]see Re: My little "Hello World"[/msg])

iistapp wrote:
LoGiCaL__ wrote:
You obviously have to write the code after learning the concept otherwise it won't stick. I like to take it in parts. If there is something I don't understand I keep at it until it makes sense and I can implement it on my own. As for your question about Dev-C++, I can't give you an answer to that as I have never used Dev-C++ . I just write my code in the nano text editor and compile with gcc .


I have no idea about what you just said in the last part there.. But compileing a program means "making it understandable" so you can run it right?

Do you run linux?



To compile the code just means to make the code so the computer can understand it. So in that respect you are right. See here for more info: http://en.wikipedia.org/wiki/Compiler

Also, I do run linux. I Just like writing in linux better than windows. The syntax varies between the two here and there. When I write in windows I usually prefer to use notepad++, which has syntax highlighting for many different languages.

-- 29 May 2012, 15:34 --

No idea what just happened to the last thing I (?) Wrote there, I'm going to try do some writing tomorrow, I'll keep this thread alive once I start getting some results and make some notes as I go along if anyone would be interested.

Would also love if someone could give me some feedback on the code I write to tell me what I can do better or what I simply did wrong.

Cheerio for now! :)

-- 30 May 2012, 11:53 --

Whooopdidoo! Here we go.

Code: Select all
// This too was standard in my program, I know iostream got something to do with some commands in c++?
#include <cstdlib>
#include <iostream>

using namespace std;

// This shit I have no idea what means either, it was just here as standard in my program too.
int main(int argc, char *argv[])
{
    cout << "You so silly";
    cout << endl;
    system("pause");
    system("cls");
    cout << "Now you have to play my game";
    cout << endl;
    system("pause");
    system("cls");
int secretNumber = 0;
    srand(time(0));
    secretNumber = rand() % 10;
    bool guessIsRight = false;
    do {
    int guess;
    cout << "Type your number (0-10): ";
    cin >> guess;
    if (guess < secretNumber)
    cout << "Too low"
    << endl;
    else if (guess > secretNumber)
    cout << "Too high"
    << endl;
    else
    guessIsRight = true;
    } while (!guessIsRight);
    cout << "Well done, you guessed right!"
    << endl;
    system("pause");
}


Happy if anyone care to tell me how messy it is and how I should go about to do it better. :)

-- 31 May 2012, 09:44 --

Code: Select all
// Includes commands like cout to the program? Still no idea what #include <cstdlib> does so I removed that too.
#include <iostream>

using namespace std;

// Still no idea what int argc, char *argv [] actually does, so I simply just removed the whole thing.
int main()
{
    cout << "You so silly";
    cin.get();
    system("cls");
   
    cout << "Now you have to play my game";
    cin.get();
    system("cls");
   
    int secretNumber = 0;
    srand(time(0));
    secretNumber = rand() % 100;
   
    bool guessIsRight = false;
    do {
    int guess;
    cout << "Type your guess (0-100): ";
    cin >> guess;
    if (guess < secretNumber)
    cout << "Too low"
    << endl;
   
    else if (guess > secretNumber)
    cout << "Too high"
    << endl;
   
    else
    guessIsRight = true;
    } while (!guessIsRight);
    system("cls");
    cout << "Well done, you guessed right!\n";
    system("pause");
}


Just did some improvements? To it, as always, would love some feedback! :)
User avatar
iistapp
Poster
Poster
 
Posts: 130
Joined: Tue Apr 21, 2009 9:44 am
Location: Norway
Blog: View Blog (0)


Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests