4 like 0 dislike
228 views

The following program stores two strings in two arrays, swaps them, and displays their new content. Is there any error? Please explain.

 

#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;

}

 

References: C From Theory

[Normal] Essay (Open question) - asked in Introduction to Computer Programming I (C) by (20.9k points)
ID: 21962 - Available when: Unlimited - Due to: Unlimited

edited by | 228 views
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.217
©2016-2024

Related questions

4 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21960 - Available when: Unlimited - Due to: Unlimited
| 263 views
5 like 0 dislike
1 answer
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21973 - Available when: Unlimited - Due to: Unlimited
| 339 views
5 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21972 - Available when: Unlimited - Due to: Unlimited
| 279 views
4 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21966 - Available when: Unlimited - Due to: Unlimited
| 252 views
4 like 0 dislike
0 answers
[Normal] Essay (Open question) - asked Feb 19, 2017 in Introduction to Computer Programming I (C) by The Contributor (20.9k points)
ID: 21965 - Available when: Unlimited - Due to: Unlimited
| 262 views
12,783 questions
183,443 answers
172,219 comments
4,824 users