All Questions
122 questions
0
votes
1
answer
111
views
Adding elements into a char array
I've been trying to make a function in C that takes a string as the input and then prints out a version of that string that only contains alpha characters.
#include <string.h>
#include <ctype....
2
votes
4
answers
117
views
Number index to array element
Task
Convert number to Chinese Pinyin. Minus sign is equal to "fu".
key-value
# num: pinyin
0: ling
1: yi
2: er
3: san
4: si
5: wu
6: liu
7: qi
8: ba
9: jiu
Code
#include <stdio.h>
...
1
vote
3
answers
182
views
How to reverse an array's values and input them into another array?
I am trying to create a code in which the person inputs a number N between 1 to 100, so they can input N amount of words-phrases up to 20 characters. The program then finds out if the said word or ...
0
votes
1
answer
76
views
Why does p+1 not produce the same result as p++ in this scenario?
Prompt: Write the following function:
void get_extension(char *file_name, char *extension);
file_name points to a string containing a file name. The function should store the extension
on the file ...
0
votes
3
answers
145
views
In C language,is it wrong to declare str[i]='\0' in the declaration part of a for loop to obtain the the value of 'i' at the last character?
I tried writing a code to reverse a string, but without calculating the length of a string.
after i gave the input it is showing segmentation fault, please help...
#include <stdio.h>
int main() ...
1
vote
2
answers
333
views
why does the variable become 0 suddenly?(c language)
i was practicing basic so i write a code to ask about user name and then i wanted to print user name character by character , then the whole name and the length of it and at the end the even numbers ...
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++)...
1
vote
1
answer
491
views
missing first character when printing string
# include <stdio.h>
# include <stdlib.h>
#include <string.h>
void main (void)
{
int size, i,j;
printf("enter no. of employee\n");
scanf("%d", &j);
printf(&...
0
votes
2
answers
58
views
A structure parameter is being skipped in my C program [duplicate]
So, this was my project:
You manage a travel agency and you want your n drivers to input their following details:
Name
Driving License No
Route
Kms
Your program should be able to take n as input(or ...
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')...
-3
votes
2
answers
125
views
why else statement cannot run in loop for C?
Here is the code and when I run it, the statements show that the loop cannot jump into else function. I am not sure which part of code is wrong.
bool isPalindrome(char A[], int n) {
int flag = 1;
...
1
vote
2
answers
170
views
how to determine last words of each string?
I have this assignment:
Enter a sequence of sentences from the keyboard into the string array (the end of entering - empty string). Determine the last word of each of these sentences.
The problem is ...
-1
votes
2
answers
106
views
Accepting string from user in an array of pointers in C us
The code tries to get names of 3 students and their marks in 3 subjects and print total score as well as average of score of each student along with their names.
#include<stdio.h>
#include<...
-1
votes
3
answers
980
views
Understanding parameters of strlen in C
I am a bit confused on why my code is not iterating a string in C programming.
Essentially.
I have this function here
int atoi(const char *s[]){
printf(" The length is %d",strlen(s));
...
1
vote
1
answer
48
views
Inconsistent output given by same code on different C compilers
Different compilers are giving different outputs for the same logic in my algorithm.
I wrote the following code for a C code exercise.
The code checks for the longest string in a string vector.
But ...