Skip to content

Improve sizeof example code #341

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

Merged
merged 1 commit into from
Mar 1, 2019
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
9 changes: 6 additions & 3 deletions Language/Variables/Utilities/sizeof.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ void loop() {

[float]
=== Notas e Advertências
Note que `sizeof` retorna o número total de bytes. Então, para os tipos de dados maiores, como ints, o loop for parece algo do tipo abaixo.
Note que `sizeof` retorna o número total de bytes. Então, para vetores de tipos de dados maiores, como `int`, o loop `for` parece algo do tipo abaixo.

[source,arduino]
----
for (i = 0; i < (sizeof(meusInts) / sizeof(int)); i++) {
// faz algo com meusInts[i]
int meusValores[] = {123, 456, 789};

// this for loop works correctly with an array of any type or size
for (i = 0; i < (sizeof(meusValores)/sizeof(meusValores[0])); i++) {
// fazer algo com meusValores[i]
}
----

Expand Down