read string c
#include <stdio.h>
void displayString(char str[]);
int main()
{
char str[50];
printf("Enter string: ");
fgets(str, sizeof(str), stdin);
displayString(str); // Passing string to a function.
return 0;
}
void displayString(char str[])
{
printf("String Output: ");
puts(str);
}
char name[20];
scanf("%s", name);#include <stdio.h>
int main() {
char *str1 = strdup("Hello");
char *str2 = malloc(sizeof(char) * (strlen(str1) + 1));
for (int i = 0; i < strlen(str1); ++i)
str2[i] = str1[i];
str2[strlen(str1)] = '\0'; // very important, the string stop to print
printf("%s --> %s\n", str1, str2);
}
Also in C:
- c memcpy
- code: 'EADDRINUSE', [0] errno: 'EADDRINUSE', [0] syscall: 'listen', [0] address: '::', [0] port: 5000
- buscar caracter
- cast from float to long c
- visual studio code
- Fibonacci program c pthread
- c print sizeof char
- excel vba convert string to a number if string is a number
- fahrenheit to celsius formula
- what is x:Name Xamarin forms
- how to modulo decimal c
- for loop c
- c file size
- C float division
- gcc on windows
- ModuleNotFoundError: No module named 'tensorboardX'
- generate all permutations of string
- how to feed a char array to function in C
- C why is is & nit used in scan f fr string
- how to read write in pipe
- lru page replacement algorithm in c
- c
- declaration in c
- C bitwise integer absolute value