0 喜歡 0 不喜歡
1.3k 瀏覽

In the following program, we want to stores two strings in two arrays, swaps them, and displays their new content. There some error. Please fix it and explain why and how in the comment after your answer.

#include <stdio.h>
int main(){
    char temp[100];
    char str1[100] = "Let see";
    char str2[100] = "Is everything OK?";
    temp = str1;
    str1 = str2;
    str2 = temp;
    printf("%s %s", str1, str2);
    return 0;
}

 

[練習] Coding (C) - 最新提問 分類:Chapter 11: Pointers |
ID: 38255 - 從幾時開始: 無限制 - 到幾時結束: 無限制
1 舉報 | 1.3k 瀏覽

30 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include * * * ******
*** ** ** * *
void change(int *str1,int *str2);

int main(){
* *** *** ** ** * **** * temp[100];
*** *** * * * **** * ** str1[100] = ** ** *
** * ** **** ** ** ** ** str2[100] = * * *** everything * ** *


* *** **** *** *** * *** = str1;
******* * * ** **** ** = str2;
* * **** *** ** *** * * = temp;
*** * * * * * ***** **
** **** **** ** ** **** *
* ***** * ***** * * * * * **
** ** ** ** **** * ** ** **** str1, str2);
** * * * * *** ** * ** 0;
}
最新回答 用戶: (-32 分)
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * ** * ** * ***
int main(){
** *** * ** ** * *** * * * * ****
* ** * * ** ** *** *str1[100] = * *** * * * ** ** *
** *** ** ** *** *** *str2[100] = *** * everything * * ***
****** **** * *** * = *str1;
* * ****** **** * ** ** = *str2;
* ** **** * * * ** * ** = *temp;
** * **** * * ** * * ** *** ** * * *str1, *str2);
* * * ** * * * ** * * 0;
}
最新回答 用戶: (-193 分)
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include ** * * *
int main()
{
*** **** * ** ** ** * temp[100];
*** *** * * **** ** str1[100] = "Let **** *
***** * ** *** ******* *** ** str2[100] = "Is everything * * *
** * **** ** ** ** *** *** *** * *** **
** **** * * * * * * = * ****** * * *
****** * * ** * = * **** ** **
*** * ** *** * = ***** * *
* ** ** ** * * * * = *p2;
* *** *** ** *** * *** * = *p3;
* * * **** * **** ** * = *p1;
* ** ** ** * *** ****** ** *** %s", str1, str2);
* ** * * ** * **** 0;
}
最新回答 用戶: (-214 分)
0 0
Case 0: Wrong output
0 喜歡 0 不喜歡
內容已隱藏
* ** ** *** * *
int **
{
**** * * * ****
** * ** char ***
* * **** * char = ** ** ** * **
* ** *** * char * * = * * * *** ** ** *
** ** ** * temp = str1;
** ** ** ** str1 =
*** *** *** str2 = temp;

* *** **** * /*
** * * * * char ** *
* * ** * * char ** ** = ** *** ** * ***
** * **** char * * ** = * * ** ***** * ** ***
* * * ** **** i = 0; i * * 100; i++)
* **** * {
*** ** ** *** * * * ** ** = * **
** * ** *** ** * **** *** ** ** * *** = ****
** * ** **** * * *** ** = **
* ** }
* *** *** * */
* * ***** **** *** ** **** * ** * *
* **** * ** * ** 0;
}
最新回答 用戶: (-285 分)
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * * ****** **
int main(){
* * * *** * * **** ***** *temp;
* * * * *** * * * **** *str1 = * ** * * *** **
** * * ** * * ** *** *str2 = * * * everything ******
** ** *** **** * * ** **** * = str1;
* * ** ** * * ** ** * *** * * = str2;
* ** * ** * * ** = temp;
** * ***** * ** ** * * ** str1, str2);
* ** * * * * * *** * * * * 0;
}
最新回答 用戶: (-16 分)
0 0
Case 0: Correct output
0 0
Case 0: Correct output
0 0
原型態為指標常數,其值不可更改;指標變數的值才能被更改
0 喜歡 0 不喜歡
內容已隱藏
#include ****** *** ** *
int main()
{
* * ***** **** * * ** * i;
* *   char *** *
** * * *** * * * * * str1[100] = * * * * * **
* * *** ** * ** * str2[100] = * ** everything *** *
** * ** * *** *** * * *** ** **** * *
** **** * * * * **** *
* * * *** ** * * * ** * ** temp[i] = str1[i];
* ** **** ***** ** * ******** **** ** str1[i] = str2[i];
* ** * ** *** * * * ** ** * * * str2[i] = ** *** * **
** * * * ** }
* * * * *
* * * ** ** * * * * * * * * *** * **** str1, str2);
* * ***** ** **** * *** ** * ** 0;
}
最新回答 用戶: (-249 分)
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
**** * * * * *
int ** *
* * **** * **** * ** ** * *
***** ** *** ** * ** * * = **** ** * * * * *
****** * * *** * ** * * * *str2 = ** * *** * * * *
* * ** ****** * * * * ** = **
** ** * ** * *** * * * *** * = str2;
*** * ** * **** * ** * **** = ** *
* * *** ** ** **** * ** * * *** * str1, *
** *** * * * ** *** *** * 0;

}
/* A name of * ** must be * by an * Here in *** code there was no * * in front of ** **** * name */
最新回答 用戶: (-304 分)
修改於 用戶:
0 0
Case 0: Wrong output
0 0
Case 0: Wrong output
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
* * ** ** *** * * ***


int *
** * * *** * * * * * * **
** *********** ** ** * *str1 = * * **** *
** * *** * ** ** ** * *str2 = ******** * *** ** * *
*** ** * * ** *** = str1;
* * * * * * ** * = str2;
*** ** *** * * ** = temp;
** * ** * *** * * ** ** * *** * * str1, *
* ** * * **** ** * * **
** * *** ***** ** 0;
}

/*
* * char ** and * * * into this array may *** due to white **
* we can * as char * ** ***
*/
最新回答 用戶: (-74 分)
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include * *** ** * * *
** ** ** *** ** *
void change(int *str1,int *str2);

int main(){
* ** ** ** * * * * * * **
*** ** *** ** * * *** * ** * * str1[100] = *** ** * ** *
** ** * * * *** * ** * str2[100] = * ** * everything ** *
* * * * * **** **** ***** ****
** * * * * * * * * ** *
* * ** ** * **** * **
*** * * ***** *** * * * ** ** str1, str2);
** * *** * * * * *** ***** * ** * 0;
}
最新回答 用戶: (-140 分)
修改於 用戶:
0 0
prog.c:1:1: error: unknown type name 'assignment'
 assignment to expression with array type
 ^~~~~~~~~~
prog.c:1:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'expression'
 assignment to expression with array type
               ^~~~~~~~~~
prog.c:1:15: error: unknown type name 'expression'
0 0
Case 0: Wrong output
0 0
Case 0: Correct output
0 喜歡 0 不喜歡
內容已隱藏
#include **** ** ** ** * *
int main(){
****** * ** ** *** ** * *temp;
*** * * *** * ** ** ** *str1 = * *** **** **
* ***** ** * * ** *str2 = ** * * everything * * *
***** *** ** * ** ********** = str1;
* ** **** ** ** * * * = str2;
* * *** ** ** *** * *** * ** = temp;
** * * * * **** *** * * * * * * str1, str2);
* * * *** * * * * ** * 0;
}
最新回答 用戶: (-254 分)
0 0
Case 0: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.71.194.180
©2016-2024

相關問題

1 喜歡 0 不喜歡
75 回答
[練習] Coding (C) - 最新提問 10月 12, 2017 分類:Chapter 3: Formatted Input/Output | 用戶: thopd (12.1k 分)
ID: 26464 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.3k 瀏覽
3 喜歡 0 不喜歡
87 回答
[練習] Coding (C) - 最新提問 10月 12, 2017 分類:Chapter 3: Formatted Input/Output | 用戶: thopd (12.1k 分)
ID: 26463 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.6k 瀏覽
12,783 問題
183,443 回答
172,219 留言
4,824 用戶