Q. Consider the below statement, can we assign a string to variable like this:

Code:
char c[100];
c = "C programming";
  • (A) Yes
  • (B) No
  • (C) ---
  • (D) ---
πŸ’¬ Discuss
βœ… Correct Answer: (B) No
Explanation: No, we cannot assign a string like this. Because string is a character array and array type is not assignable. To assign a string to the character array, we need to use strcpy() function.
Explanation by: Chandani
No, we cannot assign a string like this. Because string is a character array and array type is not assignable. To assign a string to the character array, we need to use strcpy() function.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
209
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
85%
Success Rate