Help with C++ - Writing on a specific line (in the program)
#1

Hi!

How do I choose a line to write on?

Like:

1.

2.

3.

4.

And I choose number 4.. How should I do that?.

I don't think it's too hard, as I'm still a "beginner" Or more then a beginner...
Or what I should call it... ^^.
Reply
#2

not sure what you mean by write on at all.

but if by program you mean compiler program then it depend which one you are using , is it Turbo C++ or what?
Reply
#3

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
not sure what you mean by write on at all.

but if by program you mean compiler program then it depend which one you are using , is it Turbo C++ or what?
Nope. I edited the post, I hope it might sound better now..

Pretty hard to explain.
Reply
#4

Download Net Frame C++
Reply
#5

Quote:
Originally Posted by UpSMaX
Посмотреть сообщение
Download Net Frame C++
I already have C++.
Reply
#6

pawn Код:
for(;;)
{
    system("cls");
    std::cout << "Line 1" << std::endl;
    std::cout << "Line 2" << std::endl;
    Sleep(10);
}
Reply
#7

I think you mean a program like this:

PHP код:
//Author  :  Zayan Imran <0bzayan@gmail.com>
//Purpose :  Write a message to a line.
#include "stdafx.h" //Use this only if you are running this on Visual C++
#include "iostream" //This provides some things for use, like: cout, cin, etc..
#include <string>
using namespace std//This is not useful, but it will remove a headace. 
                     //-By using this, you wont have to add "std::" to cout. 
                     //-If this isn't used, you'll have to add "std::" to cout when you use cout. std::cout << "Hello\n";
int main()
{
    
int gLine 0//An variable, which can hold numbers only.
    
loop 1,
    
hasputerror 0;
    
string option//Get what the user typed his options.
    
while(loop == 1)
    {
        
cout << "Hello - Please choose the line's number on which you want to write on: "//TIP: Usage of cout: cout << "Something"; "\n" is newline, endl as a token be also used.
        
cin >> gLine//Wait until the user has entered the number, and store it in "gLine".
        
int hasputerror 0;
        if(
gLine || gLine 4//Check if the user has entered the line's number greater than 4, or less than 1.
        
{
            
cout << "Error: The number can only range from 1-4.\nType \"tryagain\" to restart, OR, type \"exit\" to exit the program.\n"//Display an errer if so. And give 2 options.
             
hasputerror 1;
        }
        else 
//If the user has done things correct, then:
        
{
            
string line;
            
int i 0;
            
cout << "Write your line's message: ";
            
cin >> line;
            if(
gLine == 1)
            {
                
cout << "1. " << line << "\n";
                
cout << "2. \n";
                
cout << "3. \n";
                
cout << "4. \n";
            }
            else if(
gLine == 2)
            {
                
cout << "1. \n";
                
cout << "2. " << line << "\n";
                
cout << "3. \n";
                
cout << "4. \n";
            }
            else if(
gLine == 3)
            {
                
cout << "1. \n";
                
cout << "2. \n";
                
cout << "3. " << line << "\n";
                
cout << "4. \n";
            }
            else if(
gLine == 4)
            {
                
cout << "1. \n";
                
cout << "2. \n";
                
cout << "3. \n";
                
cout << "4. " << line << "\n";
            }
            
system("PAUSE"); //Wait
            
exit(1); //Exit
        
}
        if(
hasputerror == 1)
        {
            
cin >> option;
            if(
option == "exit")
            {
                
system("PAUSE");
                
hasputerror 0;
            }
            else if(
option == "tryagain")
            {
                
cout << "[-]\n[-]\n[-]\n";
                
hasputerror 0;
                
main();
            }
        }
    }

Here is an example on how to use it:

Код:
Hello - Please choose the line's number on which you want to write on: 2
Write your line's message: Hello
1. EMPTY STRING
2. Hello
3. EMPTY STRING
4. EMPTY STRING
I'vent put more comments for explanation, so I hope you understand the rest yourself. If you have any other problem in C++, then don't forget to leave me a message..
Reply
#8

ACI yeah, thanks a lot. But I think it's a bit smaller and a easier program.
Reply
#9

you REALLY should register on sites like stackoverflow..you'll get more than what you ask for in terms of help..@aci - o dear..
Reply
#10

@ Dave - you could have done it yourself ;3 I didnt clearly understood what you want.
@ Ada123 - wat dude? xd
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)