Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite appropriate C language programs WITH POINTERS instead of array indexing: 1) getline(), 2) atoi(), ********************************************************************************* 1) getline() #include int getline_(char s[], int lim); int

Rewrite appropriate C language programs WITH POINTERS instead of array indexing:

1) getline(),

2) atoi(),

*********************************************************************************

1) getline()

#include

int getline_(char s[], int lim); int getline_ptr(char* s, int lim);

int main() { char s[100]; getline_ptr(s,100); printf("%s",s);

return 0; }

int getline_(char s[], int lim){ int c, i; i=0; while(--lim >0 && (c=getchar()) != EOF && c != ' ') s[i++] = c; if (c == ' ') s[i++] = c; s[i] = '\0'; return i; }

//YOUR CODE HERE/ REWRITE WITH POINTERS int getline_ptr(char* s, int lim){ return 0; } ...

*********************************************************************************

2) atoi()

#include #include

int atoi(char s[]); int atoi_ptr(char *s);

int main() { char n[] ="255"; printf("%d ", atoi_ptr(n));

return 0; }

int atoi(char s[]){ int i, n, sign; for (i=0; isspace(s[i]); i++) ; sign = (s[i] == '-') ? -1 : 1; if (s[i] == '+' || s[i] == '-') i++; for (n =0; isdigit(s[i]); i++) n = 10 * n + (s[i] - '0'); return sign *n; }

int atoi_ptr(char *s){ // YOUR CODE HERE/ REWRITE WITH POINTERS return 0; } ...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago