Sort by

recency

|

740 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    int main() {

    char *s;
    s = malloc(1024 * sizeof(char));
    scanf("%[^\n]", s);
    s = realloc(s, strlen(s) + 1);
    //Write your logic to print the tokens of the sentence here.
    

    char *word = strtok(s, " "); while(word != NULL) { printf("%s\n", word); // Print each word in new line word = strtok(NULL, " "); // Move to next word } return 0; }

  • + 0 comments

    int main() {

    char *s;
    s = malloc(1024 * sizeof(char));
    scanf("%[^\n]", s);
    s = realloc(s, strlen(s) + 1);
    for(int i = 0;s[i]!='\0';i++){
        if(s[i] ==' '){
            s[i] = '\n';
        }
    }
    printf("%s",s);
    
    free(s);
    return 0;
    

    }

  • + 0 comments

    It’s widely used for systems programming, embedded systems, and building performance-critical applications. Skysetx

  • + 0 comments

    int i;
    for (i=0; s[i]!='\0'; i++) s[i] == ' ' ? printf("\n"): printf("%c",s[i]);
    return 0;

  • + 1 comment

    int main() {

    char str[1000];
    fgets(str,sizeof(str),stdin);
    getchar();
    for(int i=0;i<strlen(str);i++){
        char ch=str[i];
        printf("%c",ch);
        if(ch==' '){
            printf("\n");
        }
    }
    return 0;
    

    }

    • + 0 comments

      what the heck is truncated ???