[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

function STRTOL

Posted on 2004-10-01
3
Medium Priority
?
253 Views
Last Modified: 2012-08-13
Hello !
I would like to write the function strtol (char *s, char **pptr, int base)

char * ptr;
char input [80];
long number;

number = strtol(input, &ptr, 10);
if (*ptr == '\0') ...



long strtol (char *s, char **pptr, int base) {

     int i, n = 0;

     for ( i = 0 ; t[i] >='0' && t[i] <= '9' ; ++i )
          n = base * n + ( t[i] - '0');

     ( how can i make here the pointer point at the first letter met in the table ? )

     return n;
}



*sorry, french :-)*
0
Comment
Question by:matthew016
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 300 total points
ID: 12205400
*pptr = &t[i];
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 12205876
What is t[] here?If it is allocated in the function itself,then pointing to the array would be incorrect since it be non-existent once the function ends.

You should make pptr point to the first letter in the original string that was passed.

*pptr=&s[i];

or

*pptr=&(*s);
0
 
LVL 9

Author Comment

by:matthew016
ID: 12206477
Thank You !!
indeed, it was s[] ,not t[]
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question