- 2

I want to print my name in c language using a data type

Help me

23rd Dec 2021, 5:54 AM
Sudhakar Katam
18 Respostas
+ 3
the data type "string" doesn't exist in C. Use array of chars. https://www.sololearn.com/learning/2936/
23rd Dec 2021, 6:07 AM
Ayan Fox
Ayan Fox - avatar
+ 3
No, figure it out yourself.
23rd Dec 2021, 6:10 AM
Ayan Fox
Ayan Fox - avatar
+ 3
#include <stdio.h> int main(void) { char name[25] ; printf("what's your name ?") ; scanf("%s", name) ; printf ("your name is %s", name) ; return 0 ; }
24th Dec 2021, 3:06 AM
Charles mukelenge
Charles mukelenge - avatar
+ 2
You can do it with the help of array of character
24th Dec 2021, 1:39 PM
Ved Parkash Jaiswal
+ 1
Thanks bro
23rd Dec 2021, 6:11 AM
Sudhakar Katam
0
char nm[20]; fgets(nm, sizeof(nm), stdin); printf("%s", nm);
23rd Dec 2021, 8:07 AM
SoloProg
SoloProg - avatar
0
It's wrong bro
23rd Dec 2021, 8:17 AM
Sudhakar Katam
0
Thanks bro
23rd Dec 2021, 9:10 AM
Sudhakar Katam
0
Some good examples listed. If it is just your name no need to take in the input #include <stdio.h> int main(void){ char *myName = "Put your name here"; printf("My name is %s.\n", myName); } In this example changing the value of myName is not strait forward because it is considered a string literal. Like someone stated however there are no strings in C, all strings are arrays of chars, but the updated C Standard does reference "string literal".
23rd Dec 2021, 5:47 PM
William Owens
William Owens - avatar
0
devaraj%s
16th Apr 2024, 1:31 PM
Devaraj rk 143 Devaraj rk
Devaraj rk 143 Devaraj rk - avatar
- 1
Coding is done in python is easier than c language
23rd Dec 2021, 3:54 PM
Pentakota Jahnavi
- 3
Can you write it and send please
23rd Dec 2021, 6:09 AM
Sudhakar Katam
- 3
Can any one send code
23rd Dec 2021, 6:12 AM
Sudhakar Katam
- 3
Console.writeline("name")
23rd Dec 2021, 7:05 AM
Ayoub Dekhil
Ayoub Dekhil - avatar