Name:
Anonymous
2010-12-10 20:33
what am i doing wrong here
#include <stdio.h>
/* count digits, white space, others */
main()
{
int c;
int leaf,rock;
leaf == rock == 0;
while ((c = getchar()) != EOF)
if (c == 'l')
++leaf;
else if (c == 'r')
++rock;
else
printf("leaf:%d\trock:%d\n", leaf, rock);
}
yes, i know, im nothing, im worthless ;_;
Name:
Anonymous
2010-12-10 20:36
>>1
leaf == rock == 0
Why are you comparing leaf and rock to 0?
++leaf;
++rock;
Go back to C++.
yes, i know, im nothing, im worthless ;_;
You are.
Name:
Anonymous
2010-12-10 20:45
revised:
#include <stdio.h>
/* count digits, white space, others */
main()
{
int c;
int leaf,rock;
leaf = rock = 0;
while ((c = getchar()) != EOF)
if (c == 'l')
++leaf;
else if (c == 'r')
++rock;
else
printf("leaf:%d\trock:%d\n", leaf, rock);
}
thx pals
Name:
Anonymous
2010-12-10 20:46
main()
{
int c = 0;
int leaf = 0,rock = 0;
while ((c = getchar()) != EOF)
if (c == 'l')
leaf++;
else if (c == 'r')
rock++;
else
printf("leaf:%d\trock:%d\n", leaf, rock);
}
Name:
Anonymous
2010-12-10 20:50
>>5
[m][code]?
Faggot.
[spoiler]I like that.[/spoiler]
Name:
Anonymous
2010-12-11 20:29
section .bss
l resq 1
r resq 1
tmp resb 24
section .text
global _start
gc: xor rax, rax
mov rdi, rax
mov rsi, tmp
mov rdx, 1
syscall
test rax, rax
jz q
ret
q: mov byte [tmp + 0], 114
mov byte [tmp + 1], 111
mov byte [tmp + 2], 99
mov byte [tmp + 3], 107
mov byte [tmp + 4], 115
mov byte [tmp + 5], 58
mov byte [tmp + 6], 32
mov byte [tmp + 7], 32
mov byte [tmp + 8], 32
mov byte [tmp + 9], 32
mov byte [tmp + 10], 44
mov byte [tmp + 11], 32
mov byte [tmp + 12], 108
mov byte [tmp + 13], 101
mov byte [tmp + 14], 97
mov byte [tmp + 15], 118
mov byte [tmp + 16], 101
mov byte [tmp + 17], 115
mov byte [tmp + 18], 58
mov byte [tmp + 19], 32
mov byte [tmp + 20], 32
mov byte [tmp + 21], 32
mov byte [tmp + 22], 32
mov byte [tmp + 23], 10
mov r8, 10
mov rcx, qword [l]
mov rbx, 9
l1s: mov rax, rcx
xor rdx, rdx
idiv r8
mov rcx, rax
test rdx, rdx
jz l1e
add dl, 48
mov byte [tmp + rbx], dl
dec rbx
jmp l1s
l1e:
mov rcx, qword [r]
mov rbx, 22
l2s: mov rax, rcx
xor rdx, rdx
idiv r8
mov rcx, rax
test rdx, rdx
jz l2e
add dl, 48
mov byte [tmp + rbx], dl
dec rbx
jmp l2s
l2e:
mov rax, 1
mov rdi, rax
mov rsi, tmp
mov rdx, 24
syscall
mov rdi, 0
mov rax, 60
syscall
hlt
_start: call gc
cmp byte [tmp], 114
je lef
cmp byte [tmp], 108
je rck
jmp _start
lef: inc qword [l]
jmp _start
rck: inc qword [r]
jmp _start
enjoy!