#include<stdio.h> float a; double b;
To scan a double value, %lf is used as format specifier.
Therefore, the answer is scanf("%f %lf", &a, &b);
#include <stdio.h>
int main(void)
{
char string[80];
printf("Enter a string:");
gets(string);
printf("The string input was: %s\n", string);
return 0;
}
Output:
Enter a string: CuriousTab
The string input was: CuriousTab
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
int xstrlen(char s)
{
int length=0;
while(*s!='\0')
length++; s++;
return (length);
}
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
length++;
return (length);
}
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
s++;
return (length);
}
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
Example:
#include<stdio.h>
int xstrlen(char *s)
{
int length=0;
while(*s!='\0')
{ length++; s++; }
return (length);
}
int main()
{
char d[] = "CuriousTab";
printf("Length = %d\n", xstrlen(d));
return 0;
}
Output: Length = 8
The strcmp return an int value that is
if s1 < s2 returns a value < 0
if s1 == s2 returns 0
if s1 > s2 returns a value > 0
char *strnset(char *s, int ch, size_t n); Sets the first n characters of s to ch
#include <stdio.h>
#include <string.h>
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %s\n", string);
strnset(string, letter, 13);
printf("string after strnset: %s\n", string);
return 0;
}
Output:
string before strnset: abcdefghijklmnopqrstuvwxyz
string after strnset: xxxxxxxxxxxxxnopqrstuvwxyz
#include<stdio.h> float a=3.14; double b=3.14;
To print a double value, %lf is used as format specifier.
Therefore, the answer is printf("%f %lf", a, b);
fgets reads characters from stream into the string s. It stops when it reads either n - 1 characters or a newline character, whichever comes first.
Therefore, the string str contain "I am a boy\n\0"
#include<stdio.h> int main() { FILE *fs, *ft, *fp; fp = fopen("A.C", "r"); fs = fopen("B.C", "r"); ft = fopen("C.C", "r"); fclose(fp, fs, ft); return 0; }
FILE *fp; fp = fopen("source.txt", "rb");
#include<stdio.h> int main() { FILE *fp; int t; fp = fopen("DUMMY.C", "w"); t = fileno(fp); printf("%d\n", t); return 0; }
t = fileno(fp); returns the handle for the fp stream and it stored in the variable t
printf("%d\n", t); It prints the handle number.
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.