If anyone could help this humble learner I would deeply appreciate it, Im trying to put this whole function, the couts in the middle but gotoxy() on a console application doesnt seem to work, im on windows vista and using codeblocks the latest version, Maybe I have a library wrong or something.

Here is a fraction of my program, that I need to center I dont want everything to be on the right on the command prompt, Please help!, and thanks:

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <conio.h>


using namespace std;
void sub_menu1();
void sub_sub_menu();
void sub_menu2();

int menu_principal (){

system ("color 0E");

   int resp;
     cout<<"\n\nElija una funcion"<<endl;
     cout<<"======++======++=====++====++====++====="<<endl;
     cout<<"1. Nuevo Prestamo"<<endl;
     cout<<"2. Devolucion"<<endl;
     cout<<"3. Registrar Usuario"<<endl;
     cout<<"4. Salir" << endl;
     cout<<"======++======++=====++====++====++====="<<endl;
     cout<<"Digite un numero correpsondiente a la funcion"<<endl;
     gotoxy(12,8);  //<---- HERE, why cant I work?
     cin>>resp;

     switch(resp){
          case 1:
               break;

For now I just move that last cout to test it but nothing

By "doesn't seem to work" do you mean it fails to compile with an error along the lines of "'gotoxy' was not declared in this scope"? Because that's what I would expect, since gotoxy is one of those conio functions that isn't likely to be supported except on Borland compilers.

Since you're working on Windows, you might as well use something that's more likely to work with your compiler:

#include <iostream>
#include <windows.h>

using namespace std;

namespace support_for_ancient_techniqes {
    void gotoxy(SHORT x, SHORT y )
    {
        COORD coord = {x, y};
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }
}

int main()
{
    cout << "Here..." << flush;
    support_for_ancient_techniqes::gotoxy(12,8);
    cout << "And now here..." << flush;
}
commented: awsome namespace name +9

Good one Narue! Except I'd say SetConsoleCursorPosition() is cutting edge avant guard bleeding edge state of the art console mode coding for Windows!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.