Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: c style string #1913

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,11 +1116,11 @@ Here is [an example to show how Go+ interacts with C](https://github.com/goplus/
```go
import "c"

c.printf C"Hello, llgo!\n"
c.fprintf c.Stderr, C"Hi, %6.1f\n", 3.14
c.printf c"Hello, llgo!\n"
c.fprintf c.Stderr, c"Hi, %6.1f\n", 3.14
```

Here `import "c"` is used to import libc. In this example we call two C standard functions `printf` and `fprintf`, passing a C variable `stderr` and two C strings in the form of `C"xxx"` (a Go+ syntax to represent C-style strings).
Here `import "c"` is used to import libc. In this example we call two C standard functions `printf` and `fprintf`, passing a C variable `stderr` and two C strings in the form of `c"xxx"` (a Go+ syntax to represent C-style strings).

To run this demo, you need to set the `GOP_GOCMD` environment variable first.

Expand Down
10 changes: 5 additions & 5 deletions testdata/_llgo/hellollgo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ This is an example to show how Go+ interacts with C.
```go
import "c"

c.printf C"Hello, llgo!\n"
c.fprintf c.Stderr, C"Hi, %6.1f\n", 3.14
c.printf c"Hello, llgo!\n"
c.fprintf c.Stderr, c"Hi, %6.1f\n", 3.14
```

Here we use `import "c"` to import libc. It's an abbreviation for `import "github.com/goplus/llgo/c"`. It is equivalent to the following code:

```go
import "github.com/goplus/llgo/c"

c.printf C"Hello, llgo!\n"
c.fprintf c.Stderr, C"Hi, %7.1f\n", 3.14
c.printf c"Hello, llgo!\n"
c.fprintf c.Stderr, c"Hi, %7.1f\n", 3.14
```

In this example we call two C standard functions `printf` and `fprintf`, pass a C variable `stderr` and two C strings in the form of `C"xxx"`.
In this example we call two C standard functions `printf` and `fprintf`, pass a C variable `stderr` and two C strings in the form of `c"xxx"`.

To run this demo, you need to set the `GOP_GOCMD` environment variable first.

Expand Down