Good day! I'm a newbie in C. I'm trying to get an unlimited input from the user using malloc then printing the inputs after the user presses enter. My code works, but there's a warning that I don't know how to fix. Please help me. Thank you.
Here's my code:
I get the warning: passing of argument 2 of 'fgets' makes integer from pointer without a cast
What does that mean? Thank you very much
Because the second argument of fgets is an integer while malloc returns pointer to void so take it out...
hello sir
since by mentioning a integer pointer and storing the integers
by incrementing the pointer value
then what is the purpose of malloc?
u can decalre it as
in t *p;
several integers can be stored by incrementing the value of p,
hence what is the diffrence between this... (2 Replies)
Hi!
I hope this is the correct forum to post the question even if I'm a newbie...
I am a C-newbie (and really on the edge to be a C-addict ;) ) and have a question.
When should I use malloc?
To state it differently, when should I NOT use malloc?
For instance, if I have an array of... (5 Replies)
Some one please explain me what is Dynamic memory allocation and the use of malloc() function.How do we allocate memory dynamically and also the other way? (3 Replies)
Hey Guys
I am trying to implement the malloc function for my OS class and I am having a little trouble with it. I would be really grateful if I could get some hints on this problem.
So I am using a doubly-linked list as my data structure and I have to allocate memory for it (duh...). The... (1 Reply)
Hey Guys
Some of my friends have got together and we are trying to write a basic kernel similar to Linux. I am trying to implement the malloc function in C and I am using a doubly linked list as the primary data structure. I need to allocate memory for this link list (duh...) and I don't feel... (2 Replies)
Why when using realloc, john is reversed 3 times but not the other 2 names ? But if I use malloc, then the 3 names are reversed correctly ? (but then there is a memory leak)
How can I reverse all 3 names without a memory leak ?
char *BUFFER = NULL;
char *STRREVERSE(const char *STRING)
{... (5 Replies)
Hi i found code in google how to malloc an 2D array and i tried that :
#include<stdio.h>
#include<stdlib.h>
int **A;
int **B;
int main(int argc,char *argv)
{
printf("name of text : %s\n",argv);
//read arrays
int i,j;
int l,m;
int M,n;
FILE *fp;
fp=fopen(argv,"r");
... (0 Replies)
Which one is faster among malloc and new?
My understanding is that since new also has to call constructors after allocating memory it must be slower than malloc.
Am I correct? (1 Reply)
Discussion started by: rupeshkp728
1 Replies
LEARN ABOUT DEBIAN
explain_fgets_or_die
explain_fgets_or_die(3) Library Functions Manual explain_fgets_or_die(3)NAME
explain_fgets_or_die - input of strings and report errors
SYNOPSIS
#include <libexplain/fgets.h>
char *explain_fgets_or_die(char *data, int data_size, FILE *fp);
DESCRIPTION
The explain_fgets_or_die function is used to call the fgets(3) system call. On failure an explanation will be printed to stderr, obtained
from explain_fgets(3), and then the process terminates by calling exit(EXIT_FAILURE).
This function is intended to be used in a fashion similar to the following example:
explain_fgets_or_die(data, data_size, fp);
data The data, exactly as to be passed to the fgets(3) system call.
data_size
The data_size, exactly as to be passed to the fgets(3) system call.
fp The fp, exactly as to be passed to the fgets(3) system call.
Returns:
This function only returns on success; data when a line is read, or NULL on end-of-file. On failure, prints an explanation and
exits.
SEE ALSO fgets(3)
input of strings
explain_fgets(3)
explain fgets(3) errors
exit(2) terminate the calling process
COPYRIGHT
libexplain version 0.52
Copyright (C) 2008 Peter Miller
explain_fgets_or_die(3)