您好任何人都可以看到爲什麼我的程序不打印反向的刺。
我使用了gcc編譯器:gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
。C程序在gcc編譯器中跳過此程序中的循環
#include <stdio.h>
#include <string.h>
void print_reverse(char *s) {
size_t len = strlen(s);
char *t = s + len -1;
// I believe my Program is skipping this loop don't know why...
while (t <= s){
printf("%c", *t);
t = t - 1;
}
puts(t);
}
int main() {
char *juices[] = {
"dragonfrui", "waterberry", "sharonfruit", "uglifruit",
"rumberry", "kiwifruit", "mulberry", "strawberry",
"blueberry", "blackberry", "starfruit",
};
print_reverse(juices[0]);
printf("%s\n", juices[0]);
return 0;
}
變化'而(T <= S)',同時'(T> = S)'! – Blackhat002 2014-11-02 03:20:20