Skip to main content

All Questions

Tagged with
2 votes
3 answers
190 views

Why is the strlen here equal to 25?

Just so I can confirm if what I think is going on is really going on. The following code prints out 25 when I give it the (26 letter) alphabet as an input, is it because fgets always automatically ...
Guilherme Cintra's user avatar
1 vote
3 answers
104 views

Does s conversion specifier specify direction / order in which characters are written?

Does s conversion specifier specify direction / order in which characters are written? N3220 working draft, 7.23.6p8 (emphasis added): s If no l length modifier is present, the argument shall be a ...
pmor's user avatar
  • 6,530
1 vote
4 answers
150 views

C pointer concept segmentation fault

Please take a look of snippet: I am not able to understand why code is giving segmentation fault and garbage characters. #include <stdio.h> int main() { char *str[1]; str[0] = "...
naumaan's user avatar
  • 95
-3 votes
3 answers
82 views

How to get rid of the segmentation error while using C

Segmentation error in stdio.h #include <stdio.h> int main() { char arr[4]={"abcd"}; char *p; p=arr; for(int i;i<4;i++) { printf("%s\n",p[i]); ...
Jay's user avatar
  • 1
0 votes
3 answers
225 views

Using string specifier for char array?

Code: char x[]={'i',' ' ,'l','i','k','e',' ','c','!'}; printf("%s",x); Result: i like c!�@i like c!�@ I tried to print char array that not terminated with '\0' and using the string ...
Adam z's user avatar
  • 1
1 vote
3 answers
103 views

why does this not print the string?

#include<stdio.h> #include<stdlib.h> int main(){ const char *adj[] = {"swag","nice","asparagus","ugly"}; for (int i=0;i<sizeof(adj); i++)...
casimaister's user avatar
0 votes
5 answers
811 views

C programming Patterns to print the following pattern

i had try to print the following pattern but i only able to decrease the letters from the one side but not from both the side Please someone help me with this : to print this pattern this is the code ...
DUMRE ANUP's user avatar
1 vote
1 answer
48 views

Why the code is not giving the expected output here?

This code is for declaring and printing a string using pointer concept char *strPtr = "HelloWorld"; // temporary pointer to iterate over the string char *temp = strPtr; while (*temp != '\0')...
user avatar
0 votes
1 answer
320 views

Print char pointer array in a struct with printf in c

I am trying to print the names of my array with a for but the output gives me random letter and signs, I cant cast it correctly to print the names of the struct. typedef struct{ // uint8_t name; ...
cesar's user avatar
  • 23
1 vote
2 answers
97 views

My program can't print a single-character string [duplicate]

I am trying to learn C, but for some reason my program doesn't want to print letters. It can print everything else like integers and floats just fine. It doesn't give me an error as well, it just ...
user avatar
0 votes
2 answers
199 views

malloc works with int but not with strings

Im a very new to C language. Im trying to learn about to memory allocation with the next examples. If I allocate memory for a integer like this: int* pint = (int*)malloc(sizeof(int)); if (...
Raxabi's user avatar
  • 111
1 vote
2 answers
64 views

how do I access a character from 2-D char string

#include <stdio.h> #include <string.h> #define max 50 #define len 30 char text[max][len]; void main(){ register int i; printf("Enter an empty line to quit\n"); for(i =...
Nancy_it_is's user avatar
1 vote
1 answer
40 views

Failure in Pointer Dereferencing in C while using same function and variable

I am trying to using C to work with files with different extensions. So this is the code that I have written. #include <stdio.h> #include <windows.h> #include <unistd.h> #include <...
Sammy1410's user avatar
1 vote
2 answers
53 views

Why I cannot access the first read char array after reading a series of others in C?

I wanted to read a phrase and a series of numbers/alphabetic separated by ",". I read the first string then I print it (works fine). I read the first string, read 62 of those series and try ...
Rares Olteanu's user avatar
1 vote
3 answers
119 views

Why unwanted character getting showed when I print a string

#include<stdio.h> int main() { char main[]="Structured Programming"; char copy[30]; for (int i = 0; main[i] !='\0' ; i++) { copy[i]=main[i]; } printf(&...
Rifat Ahmed Tusher's user avatar

15 30 50 per page
1
2 3 4 5
7