All Questions
12 questions
-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
votes
2
answers
175
views
Trying to reverse a C-string but it is not working
I am trying to reverse this C-string and I thought I did it correct but the string remains the same when it passes through the function.
#include <stdio.h>
char* reverse(char* string);
int ...
0
votes
1
answer
210
views
I can not understanding this portion of code for this token identification program
I have got this code reference from a website and practicing with this.
When I am trying to working with malloc() function then how we getting the value from right-left+2
// Extraction string
char* ...
1
vote
1
answer
41
views
applying cipher code given as argv to userinput
I am trying to write a function that takes in variables cipher, userinput, alphabet and outputs the replace letters. for example at execution it takes in an argument argv ZYXWVUTSRQPONMLKJIHGFEDCBA. ...
1
vote
1
answer
42
views
Exception thrown: Write access violation using pointers [duplicate]
I've got this function below that takes a string and reverses it in C, but only using pointers. However, for some reason, I get this error every single time. This code is almost copy and paste from a ...
0
votes
3
answers
174
views
pass char to function
i need to write a function that randomize length of string, allocate dynamic memory for it and than randomize small letters inside it.
the main program should print 15 words from the function.
the ...
1
vote
2
answers
788
views
Heap buffer overflow caused by single line
Currently trying to work on my C (very new to it) by doing some leetcode questions. I'm puzzled by this issue, as it gives me a heap buffer overflow but only because of a single line. interpret() is ...
2
votes
2
answers
167
views
My function that reverses a string gives me "stack smashing detected"
I am trying to write a function that reverses a given string but it gives me "stack smashing detected".
Here is my code:
void reverse(char *str2) {
int i, j;
char temp;
for (i = ...
0
votes
2
answers
396
views
Why do I have garbage characters at the end of my character array?
I have the following code (from K&R Exercise 2-4):
#include <stdio.h>
#define MAXLINE 1000 /* maximum input line size */
void squeeze(char s1[], char s2[]);
/* Exercise 2-4. Write an ...
2
votes
3
answers
123
views
segmentation fault, c programm
I had to write a program in c as a homework assignment. The program checks if the inputed string is a palindrome. Unfortunately I am getting a segmentation fault error when executing my program.
...
-1
votes
1
answer
131
views
This is my code for the CS50 Readability assignment. Why is the global variable in my function not updating? It always gives 0 words [closed]
Is the problem checking it using ASCII code because this is what we learnt in CS50. I'm trying to check for spaces and the ASCII code for a space is 32.
#include <ctype.h>
#include <cs50.h>...
-1
votes
4
answers
2k
views
Why !strcmp is used instead of strcmp?
Here I wrote a code to find out whether a word is available or not.
#include <stdio.h>
#include <string.h>
char *names[] = {"Sushant", "Jhon", "Robin", "...