[間違った例] persistent int sum = 0, i = 0; persistent_load(); for (; i <= 100; i++) { sum += i; persistent_save(0); } printf("sum=%d\n", sum);
[正しい例] persistent int sum = 0, i = 0; persistent_load(); for (; i <= 100; i++) { persistent_save(0); sum += i; } printf("sum=%d\n", sum);
while (i <= 100) { persistent_save(0); sum += i; i++; }
khpc000>pbdtol dump p-vars.pbd format: persistent_binary_memimage_IA32_v00 note: @hkawai3.khpc000.test i (4bytes) (flags=0x00000000) : 64 00 00 00 (=100) sum (4bytes) (flags=0x00000000) : 56 13 00 00 (=4950)
コメント | お名前 | NameLink | |