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

修复 两个语句问题 ch12-01-accepting-command-line-arguments.md #836

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/ch12-01-accepting-command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $ cargo run -- searchstring example-filename.txt

<span class="caption">示例 12-2:创建变量来存放查询参数和文件路径参数</span>

正如之前打印出 vector 时所所看到的,程序的名称占据了 vector 的第一个值 `args[0]`,所以我们从索引为 `1` 的参数开始。`minigrep` 获取的第一个参数是需要搜索的字符串,所以将其将第一个参数的引用存放在变量 `query` 中。第二个参数将是文件路径,所以将第二个参数的引用放入变量 `file_path` 中。
正如之前打印出 vector 时所看到的,程序的名称占据了 vector 的第一个值 `args[0]`,所以我们从索引为 `1` 的参数开始。`minigrep` 获取的第一个参数是需要搜索的字符串,所以将第一个参数的引用存放在变量 `query` 中。第二个参数将是文件路径,所以将第二个参数的引用放入变量 `file_path` 中。

我们将临时打印出这些变量的值来证明代码如我们期望的那样工作。使用参数 `test` 和 `sample.txt` 再次运行这个程序:

Expand Down
Loading