Question:
Why doesn’t strcat (string, ‘!’); work ?
Answer:
Source: CoolInterview.com
'!' represents a char and not a string. strcat (string, "!"); should work. Source: CoolInterview.com
Answered by: Amit C | Date: 6/15/2008
| Contact Amit C
strcat() will works for strings but not for characters Source: CoolInterview.com
Answered by: Kishore | Date: 6/16/2008
| Contact Kishore
string(string,"?!?") string must be an array of charecters. Source: CoolInterview.com
Answered by: anupama | Date: 7/10/2008
| Contact anupama
It works. Check out this code
int main() { char arr[10]="ABC";
printf("%s ",strcat(arr,"a"));
return 0; } Source: CoolInterview.com
Answered by: abhimanipal | Date: 3/16/2010
| Contact abhimanipal
It actually works... #include<stdio.h> #include<string.h> void main() { printf(strcat("Hello","!"); } Run d above code n see in d output window...U'l get output as Hello! Source: CoolInterview.com
Answered by: Ashwini | Date: 4/5/2010
| Contact Ashwini
strcat concatenate the two string.
strcat(string,"!"); will work because ! is enclosed within double quotes and it is considered as string.
strcat(string,'!'); will not work because ! is enclosed within the single quotes,it is considered as character. Source: CoolInterview.com
Answered by: Sharkselva | Date: 4/24/2010
| Contact Sharkselva
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|