-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main() { | ||
char *input = NULL; | ||
size_t len = 0; | ||
ssize_t read; | ||
printf("Enter text (Ctrl+D to quit):\n"); | ||
read = getline(&input, &len, stdin); | ||
|
||
if (read != -1) { | ||
printf("Entered: %s", input); | ||
} else { | ||
printf("error reading input\n"); | ||
} | ||
|
||
free(input); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@[translated] | ||
module main | ||
|
||
fn C.getline(__lineptr &&u8, __n &usize, __stream &C.FILE) isize | ||
|
||
struct Lldiv_t { | ||
quot i64 | ||
rem i64 | ||
} | ||
|
||
struct Random_data { | ||
fptr &int | ||
rptr &int | ||
state &int | ||
rand_type int | ||
rand_deg int | ||
rand_sep int | ||
end_ptr &int | ||
} | ||
|
||
struct Drand48_data { | ||
__x [3]u16 | ||
__old_x [3]u16 | ||
__c u16 | ||
__init u16 | ||
__a i64 | ||
} | ||
|
||
fn main() { | ||
input := (unsafe { nil }) | ||
len := 0 | ||
read := isize(0) | ||
C.printf(c'Enter text (Ctrl+D to quit):\n') | ||
read = C.getline(&input, &len, C.stdin) | ||
if read != -1 { | ||
C.printf(c'Entered: %s', input) | ||
} else { | ||
C.printf(c'error reading input\n') | ||
} | ||
C.free(input) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main() { | ||
char *input = NULL; | ||
size_t len = 0; | ||
ssize_t read; | ||
printf("Enter text (Ctrl+D to quit):\n"); | ||
read = getline(&input, &len, stdin); | ||
|
||
if (read != -1) { | ||
printf("Entered: %s", input); | ||
} else { | ||
printf("error reading input\n"); | ||
} | ||
|
||
free(input); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@[translated] | ||
module main | ||
|
||
fn C.getline(__linep &&u8, __linecapp &usize, __stream &C.FILE) isize | ||
|
||
struct Lldiv_t { | ||
quot i64 | ||
rem i64 | ||
} | ||
|
||
fn main() { | ||
input := (unsafe { nil }) | ||
len := 0 | ||
read := isize(0) | ||
C.printf(c'Enter text (Ctrl+D to quit):\n') | ||
read = C.getline(&input, &len, C.__stdinp) | ||
if read != -1 { | ||
C.printf(c'Entered: %s', input) | ||
} else { | ||
C.printf(c'error reading input\n') | ||
} | ||
C.free(input) | ||
return | ||
} |