994 questions
3
votes
3
answers
155
views
remove a character by using conditional statement
recently just practiced the problem 67 in Leetcode This problem is like you would be given two binary string, and you have to calculate the sum of these two binary string and return the result.For ...
-5
votes
3
answers
111
views
How to fix printing declared function [duplicate]
I'm still new at functions and I tend to print the function which I don't know how to print the declared function. It prints "1" and not "John".
#include <iostream>
void ...
3
votes
4
answers
172
views
Change pointer adress inside function in C
I'm trying to make a program that deletes extra white spaces from a string. It should keep one space but delete any extra.
I wrote this code, which works up until the point I have to change the passed ...
1
vote
2
answers
65
views
Line extraction in a char
Hi i'm trying to write a recursive function to extract each line of a string. I don't know why it doesn't work i spent 2 hours trying to find the issue.
#include <string.h>
#include <stdlib.h&...
4
votes
6
answers
263
views
Function returning 101 and -101 instead of 1 and -1
So my professor gave us the assignment to code a function that works exactly like strcmp() but without using any library functions. I came up with the following code but instead of returning 1 or -1 ...
0
votes
5
answers
93
views
a heap-use-after-free wrong in the question--Design MyLinkList (LeetCode No.707)
Below is my C code for LeetCode no. 707 "Design Linked List":
typedef struct MyLinkedList{
int val;
struct MyLinkedList *next;
} MyLinkedList, *LinkList;
MyLinkedList* ...
0
votes
2
answers
96
views
Is it legal to have a function prototype slightly different from its definition?
//my_struct.h
typedef struct my_struct_t *my_handle;
void f1(my_handle handle);
void f2(my_handle handle);
//my_struct.c
#include "my_struct.h"
typedef struct
{
int a;
int b;
} ...
0
votes
2
answers
93
views
Avoid names of variables ending into function definitions in R
I would like to use values within variables for defining functions in R. However, after declaring the function I can still see the variable names instead of their values inside the function definition....
4
votes
2
answers
130
views
Function definition with prototype vs without prototype
There are (source):
void f(); // declaration (1)
void f(void); // declaration with prototype (2)
void f() { ... } // definition (3)
void f(void) { ... } // definition with ...
3
votes
0
answers
65
views
For function definition, what is the difference between using partial application, a lamba expression or put the arguments next to the name? [duplicate]
What are the differences between the three syntaxes
funName l = map fun l
funName = \ l -> map fun l
funName = map fun
In general it does the same thing however in some cases it differs.
The ...
2
votes
3
answers
147
views
Deleting selected element in a doubly linked list [duplicate]
I have written a code on deleting a node by comparing its data from the data given. If equal, it deletes the node. My problem is that my code will delete every node in the list except the last node, I ...
-3
votes
3
answers
145
views
How does does compiler know the definition of pre defined function even before linker haven't linked object file and library file?
We know that definition of pre defined functions are in library files, and it is the job of linker to link that library code(which is already compiled) to our object file (which has been created after ...
2
votes
1
answer
61
views
Why does the following base case for recursion in C not work?
I am practicing recursion function in C. The question is to create a recursive function to print a sum of all of the elements (int) in an array without changing the main function.
I know how to write ...
0
votes
1
answer
55
views
C++ Define member functions for all template specialized classes
I have a templated class foo<T> which is specialized in many different ways.
Some of which have a lot of common code that relies on specialized functions.
For example, consider the following:
#...
1
vote
2
answers
219
views
Returning the remaining string in strtok function?
I am writing my own strtok function. How do I make it so that it will return the remaining string as an output parameter?
Here is what I made so far.
char *mystringtokenize(char **string, char ...