So I should never cast? Like is that a bad practice?
Type: Posts; User: Timmy10
So I should never cast? Like is that a bad practice?
I think my functions are ok but when interconnected with each it is not doing what I want it to. Any way in how to fix it?
# include <stdio.h>
#include <stdlib.h>
# define MAX_LIMIT 42
I understand what you are trying to get at but what exactly is my mistake? Please bear with me.
I don't understand what you mean by me casting the return value of malloc.
@laserlight
When trying to compile these are the errors I am facing. Unsure of how to fix them.
In function ‘main’:
main.c:31:15: warning: assignment from incompatible pointer type...
I did what you mentioned but it is still not working. Sorry for causing you inconvenience.
Could you kindly please explain what casting the result of malloc means?
I wrote this code but cannot figure out the issues that arise when trying to compile.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int find_First_Letter (char **word_Array,...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmpstr(void* v1, void* v2)
{
char *a1 = *(char**)v1;
char *a2 = *(char**)v2;
return strcmp(a1, a2);
Sorry @salem. Posting it again
@salem I made a few tweaks. Now it comes to segmentation fault.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmpstr(void* v1, void* v2)
{
So I got the sorting program to work when I set the array without any numbers. However when reading from a file which has numbers before the word it is not behaving the way I want it to.
...
I'm sorry but I just cannot seem to find the error.
So, I did this and now it does not compile.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAX_QUERIES 12
#define N_DIGITS 4
The following program works when valid input is entered. When invalid input is entered it goes into a loop and stops working. I have included the code along with how I want the code to behave when...
My code compiles and runs but some parts are not giving the required output. I cannot seem to figure it out. Included are the code and the desired output.
16247
16248
16249
...
What would that loop look like?
How do I fix that error?
It terminates after computing for the first input.
So I am writing a code where the program will keep asking for a number and calculate its prime factorization unless the user enters 1 or less. What am I doing wrong?
#include<stdio.h>
int...
Only stdio.h is allowed. The ABRACADABRA language has just five lowercase letters a,b,c,d,r, and every combination of these letters (but no other letters) is a word in the ABRACADABRA language. For...
so goto is always bad?
There can be spaces between the other characters just not between a and Y. Also if the equation is valid like you can see in the second run where bla bla is inputted it will still give out the...
I can only use <stdio.h> for the problem.
I wrote most of it out but cannot figure out the special cases.
#include <stdio.h>
#define VARIABLE_NAME 'Y'
int main()
{
double a, b, c, d;
...