Giter Site home page Giter Site logo

How to read user input? about impala HOT 2 CLOSED

enty8080 avatar enty8080 commented on June 6, 2024
How to read user input?

from impala.

Comments (2)

richardmembarth avatar richardmembarth commented on June 6, 2024

The focus of AnyDSL is mainly on writhing high-performance libraries. For input/output, we rely typically on C/C++.
See https://anydsl.github.io/Tutorial.html for how this can be done.

from impala.

madmann91 avatar madmann91 commented on June 6, 2024

Alternatively, you can import C functions, like fgets:

struct FILE {}
extern "C" {
    fn "stdin_" stdin() -> &FILE;
    fn fgets(&mut [u8], i32, &FILE) -> &[u8];
}

fn main() -> i32 {
    let mut str : [u8 * 256];
    fgets(&mut str, 256, stdin());
    0
}

You'll need to compile and link with the C standard library and this additional C file containing a definition for stdin:

#include <stdio.h>
void* stdin_(void) { return stdin; }

Note that this will not work if you compile the above file as a C++ file as the name of the function will be mangled (use gcc, not g++).

from impala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.