-1

ポインターを使用して文字列を入力して、スペースを「-」(ダッシュ記号) に置き換える必要があります。

入力は次のようになります。

空は青い

出力 :

空は青い

コーディングをコンパイルして仕事を始めるのに問題があります。

    #include <stdio.h>
#include <string.h>
#include <stdlib.h>
char result;

int main()
{
    char string[100], *space;
    {
    printf("Enter a string here: \n"); //Enter a string in command prompt
    gets(string); //scans it and places it into a string
    space = string;
    printf("%s\n", space);
    result = space.Replace(" ", "-");
    }
    getchar();
}
4

2 に答える 2

0
#include <stdio.h>
#include <conio.h>
#include <string.h>

int main()
{
    char string[100], *space;
    {
    printf("Enter a string here: \n"); //Enter a string in command prompt
    gets(string); //scans it and places it into a string
    space = string;

    while (*space == ' '? (*space = '-'): *space++);
    printf("%s\n", space);
    }
    getchar();
}

あなたが提案したことをしましたが、それでも機能しません。それはコンパイルしますが

于 2013-11-13T23:59:37.177 に答える