c++ to java

This is a discussion on c++ to java within the Tech Board forums, part of the Community Boards category; the problem: say you input from a file "name1 1 2 3 4 5 6" "name2 1 2 3 4 ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    91

    c++ to java

    the problem:

    say you input from a file

    "name1 1 2 3 4 5 6"
    "name2 1 2 3 4 5 6"
    "name3 1 2 3 4 5 6
    "name4 1 2 3 4 5 6"
    "name5 1 2 3 4 5 6"
    "name6 1 2 3 4 5 6"


    you want to store "name" as a string, and 1 2 3 4 5 6 as int.

    whats the equivalent of the methods putback(), get(), getline() in java?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    Code:
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
    String s = r.readLine(); // Read a line from the console
    int c = r.read(); // Read a single character
    I'm not sure what the equivalent function is for putback().
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    strcat() getc() and gets()

    actually theres a version of putback() in C as well, just #include <iostream>
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    Quote Originally Posted by abachler View Post
    strcat() getc() and gets()

    actually theres a version of putback() in C as well, just #include <iostream>
    What are you talking about? He asks for the Java version of some C++ functions, and you give him 3 random C functions? Then tell him to include <iostream> in a C application?
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by bithub View Post
    What are you talking about? He asks for the Java version of some C++ functions, and you give him 3 random C functions? Then tell him to include <iostream> in a C application?
    <Facepalm> thought he was asking for C++ equivalents of a java function... haven't had my mornign coffee yet.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  6. #6
    The larch
    Join Date
    May 2006
    Posts
    3,573
    It is unclear, though, why you'd ask Java questions here...
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    This isn't a C++ thread. Moved.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 03:12 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 03:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 10:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 01:37 AM
  5. C or Java as a first language
    By CorJava in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 10-23-2002, 06:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21