How to iterate over a string in C?

前端 未结 13 1236
花落未央
花落未央 2020-11-28 06:43

Right now I\'m trying this:

#include 

int main(int argc, char *argv[]) {

    if (argc != 3) {

        printf(\"Usage: %s %s sourcecode inpu         


        
相关标签:
13条回答
  • 2020-11-28 07:18
    1. sizeof() includes the terminating null character. You should use strlen() (but put the call outside the loop and save it in a variable), but that's probably not what's causing the exception.
    2. you should use "%c", not "%s" in printf - you are printing a character, not a string.
    0 讨论(0)
提交回复
热议问题