In C, given a string variable str, which of the following two should be preferred to print it to stdout?
1) puts(str);
2) printf(str);
puts() can be preferre...
Share
sizeof()
Sizeof operator is a compile time unary operator which can be used to compute the size of its operand.
The result of sizeof is of unsigned integral type ...
Share
Strings are defined as an array of characters. The difference between a character array and a string is the string is terminated with a special character ‘&#x...
Share
Let us consider the below program.
#include<stdio.h>
void swap(char *str1, char *str2)
{
  char *temp = str1;
  str1 = str2; ...
Share
In C, a string can be referred to either using a character pointer or as a character array.
Strings as character arrays
char str[4] = "GfG"; /*One...
Share
Image a situation where we want to use or print a long long string in C or C++, how to do do this?
In C/C++, we can break a string at any point in the middle using tw...
Share
Write an efficient C program to print all the duplicates and their counts in the input string
Algorithm: Let input string be “geeksforgeeks”
1: Constr...
Share
Given a string, find the first non-repeating character in it. For example, if the input string is “GeeksforGeeks”, then output should be ‘f...
Share
Solution: Use sprintf() function.
#include<stdio.h>
int main()
{
    char result[50];
    float num = 23.3...
Share
Find the length of a string without using any loops and string.h in C. Your program is supposed to behave in following way:
Enter a string: GeeksforGeeks (Say user e...
Share