cprint

i dont what to use

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 2032 Views - Last Post: 09 July 2008 - 10:51 AM Rate Topic: -----

#1 qaz1134  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 21-May 08

cprint

Post icon  Posted 08 July 2008 - 12:19 AM

is cprint diffenrent form printf("");?

what about cout ans cint???? how are they declared?

:stupid:
Is This A Good Question/Topic? 0
  • +

Replies To: cprint

#2 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: cprint

Posted 08 July 2008 - 02:50 AM

cprint?

cout and cin are C++ standards for console input and output. Here's an example program that uses them:
#include <iostream> // input/output stream

using std::cout; // using cout from the std namespace
using std::cin;  // using cin from the std namespace
using std::endl; // using endl from the std namespace

int main () {
    cout << "Enter a number: "; // Console OUT a prompt
    int a; // declare an int
    cin >> a; // Console IN some data
    cout << "You entered " << a << endl; // output a string and the variable

    cin.get (); // pause the window
    return EXIT_SUCCESS; // program was executed successfully
}

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 red_4900  Icon User is offline

  • Code T(h)inkers
  • member icon

Reputation: 21
  • View blog
  • Posts: 1,120
  • Joined: 22-February 08

Re: cprint

Posted 08 July 2008 - 03:08 AM

I know printf, I know cout, but what is cprintf?
Was This Post Helpful? 0
  • +
  • -

#4 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: cprint

Posted 08 July 2008 - 03:16 AM

Do you mean sprintf(); ?
Was This Post Helpful? 0
  • +
  • -

#5 subhendu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-July 08

Re: cprint

Posted 08 July 2008 - 03:18 AM

View Postgabehabe, on 8 Jul, 2008 - 02:50 AM, said:

cprint?

cout and cin are C++ standards for console input and output. Here's an example program that uses them:
#include <iostream> // input/output stream

using std::cout; // using cout from the std namespace
using std::cin;  // using cin from the std namespace
using std::endl; // using endl from the std namespace

int main () {
    cout << "Enter a number: "; // Console OUT a prompt
    int a; // declare an int
    cin >> a; // Console IN some data
    cout << "You entered " << a << endl; // output a string and the variable

    cin.get (); // pause the window
    return EXIT_SUCCESS; // program was executed successfully
}

Hope this helps :)



There are nothing cprintf()?
Was This Post Helpful? 0
  • +
  • -

#6 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: cprint

Posted 08 July 2008 - 03:23 AM

If you mean sprintf(); then it's used to concatenate strings, like so:
#include <iostream> // input/output stream
#include <string> // sprintf ()

using namespace std;

int main () {
    char * x = "hello";
    char * y = "world";
    char * z;
    sprintf (z, "%s %s!", x, y);
    cout << z << endl;

    cin.get (); // pause the window
    return EXIT_SUCCESS; // program was executed successfully
}


Was This Post Helpful? 0
  • +
  • -

#7 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: cprint

Posted 08 July 2008 - 05:32 AM

View Postqaz1134, on 8 Jul, 2008 - 12:19 AM, said:

is cprint diffenrent form printf("");?

what about cout ans cint???? how are they declared?

:stupid:


Not too sure what "cint" is either, I think you may mean cin?
Was This Post Helpful? 0
  • +
  • -

#8 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: cprint

Posted 08 July 2008 - 05:36 AM

Yeah, they meant cin, hence why I showed it in an example. :)
Was This Post Helpful? 0
  • +
  • -

#9 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: cprint

Posted 08 July 2008 - 05:39 AM

View Postgabehabe, on 8 Jul, 2008 - 05:36 AM, said:

Yeah, they meant cin, hence why I showed it in an example. :)


Oops, I apologize I missed that :blink:
Was This Post Helpful? 0
  • +
  • -

#10 gkgranada  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 06-July 08

Re: cprint

Posted 08 July 2008 - 05:47 AM

the c in cprintf stands for color. i'm still trying to figure out how to use it for myself, so i can only tell you that much.

your output, when you use cprintf, would be in color.
Was This Post Helpful? 0
  • +
  • -

#11 red_4900  Icon User is offline

  • Code T(h)inkers
  • member icon

Reputation: 21
  • View blog
  • Posts: 1,120
  • Joined: 22-February 08

Re: cprint

Posted 08 July 2008 - 10:10 AM

View Postgabehabe, on 8 Jul, 2008 - 03:23 AM, said:

If you mean sprintf(); then it's used to concatenate strings, like so:
#include <iostream> // input/output stream
#include <string> // sprintf ()

using namespace std;

int main () {
    char * x = "hello";
    char * y = "world";
    char * z;
    sprintf (z, "%s %s!", x, y);
    cout << z << endl;

    cin.get (); // pause the window
    return EXIT_SUCCESS; // program was executed successfully
}


sorry my english sucks. what do the code do actually? point the *z to the words in both *x and *y? what does the first parameter in sprintf() function do?
Was This Post Helpful? 0
  • +
  • -

#12 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: cprint

Posted 08 July 2008 - 12:09 PM

The first parameter is the target string, which the new string will be written to. Think of how you would use printf(); because it's a lot like that... basically, you specify the string, and then give the string a value with similar syntax to printf();

And your English is really good, I've always thought that :)
Was This Post Helpful? 0
  • +
  • -

#13 Hyper_Eye  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 39
  • View blog
  • Posts: 116
  • Joined: 13-September 07

Re: cprint

Posted 08 July 2008 - 02:09 PM

View Postgabehabe, on 8 Jul, 2008 - 05:23 AM, said:

If you mean sprintf(); then it's used to concatenate strings, like so:


I wouldn't define sprintf() that way. I would define it as "a function that prints into a stored a string with support for variable arguments" or as "printf into a stored string." I say that because it is useful for much more then string concatenation (for which strcat() is generally acceptable.) It can be used to format a string with variable data. For example:

sprintf(string, "Hello %s, you are %d years old.", name, age);
show_greeting_dialog(string);


That's pretty nifty and useful! :)

This post has been edited by Hyper_Eye: 08 July 2008 - 02:10 PM

Was This Post Helpful? 0
  • +
  • -

#14 qaz1134  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 121
  • Joined: 21-May 08

Re: cprint

Posted 09 July 2008 - 10:44 AM

it is not sprintf();[/b]

it
looks like this:
 textbackground(0);
 textcolor(2);

 cprintf("SCANCODE=%d,  ASCII-Ch=%c",ch,ch);
 
 printf("\n\n");
 puts("**************************");
 printf("\n\n");
 getch();



This post has been edited by qaz1134: 09 July 2008 - 10:50 AM

Was This Post Helpful? 0
  • +
  • -

#15 Hyper_Eye  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 39
  • View blog
  • Posts: 116
  • Joined: 13-September 07

Re: cprint

Posted 09 July 2008 - 10:47 AM

But the code you just posted didn't demonstrate a cprint() function. Your code has cprintf().
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2