Symantec Interview Question: Was asked a few C++ questions... | Glassdoor

Interview Question

STAR Intern Interview(Student Candidate) Culver City, CA

Was asked a few C++ questions about classes and then was

  asked to code a function that converts a string of digits to the actual integer value (without using atoi). ex. string a = "1234"; int b; //some code to make b = 1234

Interview Answer

1 Answer


int atoi(char s[])
int i, n=0;
for(i=0; s[i]>='0' && s[i]<='9'; i++)
  n = 10*n + (s[i] - '0');
return n;

Anonymous on Mar 24, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.