検索結果 11 件
- 3年前
- フォーラム: C言語何でも質問掲示板
- トピック: 質問
- 返信数: 5
- 閲覧数: 4980
質問
#include<stdio.h> #define SIZE 100 int main(void){ char str[SIZE]={'\0'}; char kensaku[SIZE]={'\0'}; int sum=0; int len=0; int i; printf("文字列を入力>"); scanf("%s",str); printf("検索する文字列を入力>"); scanf("%s",kensaku); while(str[len] !='\0'){ //文字数のカウント len++; while(kensaku[sum] !='\0'){ sum++; } } printf("...
- 3年前
- フォーラム: C言語何でも質問掲示板
- トピック: 質問2
- 返信数: 4
- 閲覧数: 4785
Re: 質問2
ありがとうございます! ついでにこれもいいでしょうか? /* 21EO0122 樋渡悠 */ #include<stdio.h> #define SIZE 100 int main(void){ char str[SIZE]={'\0'}; char kensaku[SIZE]={'\0'}; int sum=0; int len=0; int i; printf("文字列を入力>"); scanf("%s",str); printf("検索する文字列を入力>"); scanf("%s",kensaku); while(str[len] !='\0'){ //文字数のカウント len++; w...
- 3年前
- フォーラム: C言語何でも質問掲示板
- トピック: 質問2
- 返信数: 4
- 閲覧数: 4785
質問2
またまたわからない箇所が出てきましたので、 教えていただけると幸いです。 #include<stdio.h> #define SIZE 100 unsigned str_copy(const char *ptsr1,const char *pstr2); int main(void){ char str1[SIZE]; char str2[SIZE]; printf("文字列の入力>"); scanf("%s",str1); str_copy(str1,str2); printf("str1 : %s\n",str1); printf("str2 : %s\n",str2); return 0...
- 3年前
- フォーラム: C言語何でも質問掲示板
- トピック: 質問
- 返信数: 7
- 閲覧数: 5946
Re: 質問
ありがとうございます。でもまだ0になります。 0にならないようにするには、psum ではなく、psum「が指している変数」を書き換えるようにするといいと思います。 void array_sumof(int *vc,int no, int *psum){ int i; for(i=0;i<no;i++){ // psumを書き換える // psum+=*vc; // psumが指している変数を書き換える *psum+=*vc; } } また、配列の先頭要素 *vc を no 回足すのではなく、配列の各要素 vc[i-no] を足すようにしたほうがよさそうですね。 「今日中」に間に合わないようにす...
- 3年前
- フォーラム: C言語何でも質問掲示板
- トピック: 質問
- 返信数: 7
- 閲覧数: 5946
Re: 質問
見てくれた人でコンパイルして、0にならない方法がわかる方い教えていただけると助かります。