+ 1

Program of strings is compiling error,would you help me?

#include<stdio.h> int main() {     int str[]={'g','l','o','b','y'};     printf("A%c ",str);     printf("A%s ",str);     printf("A%c ",str[0]);     return 0; }

27th Jul 2020, 5:47 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
8 Respostas
+ 1
Yaa ok
27th Jul 2020, 5:57 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
It's a great deal to get compile, but it is solved in recent code exams I have done
27th Jul 2020, 6:01 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
But without any changes in the program,the answer is mentioned , as A character A Ag i guess not sure
27th Jul 2020, 6:11 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
The question is the same I have mentioned , and based exam I have attended to the correct answer is something like A character A ag, but when I am running it I am not getting the program compiled.
27th Jul 2020, 6:18 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
Ok
27th Jul 2020, 6:21 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
I guess, it is may be printf("%Ac", *str) ; %s not works on integer array.. So it may be charecter array...
27th Jul 2020, 7:25 AM
Jayakrishna 🇮🇳
0
%s is address of the int/string storing name
27th Jul 2020, 7:30 AM
Yukthamukhi Rudra
Yukthamukhi Rudra - avatar
0
As far i know, %s returns charecter array or string in c. Do you want to know the program by removing errors? It need atleast 2 changes to work without any warning.. Otherwise it prints A Ag Ag with warnings... (If *str, then it returns g) Edit : Here this, With good examples: https://aticleworld.com/format-specifiers-in-c/
27th Jul 2020, 8:00 AM
Jayakrishna 🇮🇳