Archive for May, 2013

This is a link to my program on github that converts char into int.

https://github.com/admix/admixSoft/blob/master/OOP344/ascToInt.cpp

Would love to get a feedback or suggestions πŸ™‚

//  This block of code performs conversion char to int
//  Returning '0' if not a number
//  ascToInt.cpp
//  Created by Alexander on 2013-05-21.
//  Copyright (c) 2013 Alexander. All rights reserved.
//
#include <iostream>

using namespace std;
int ascToInt(const char *ch);

int main(){  //sample main() where you can test the function
  int num;
  char* str;
  cout<<"Enter a number: ";
  cin>>str;
  num = ascToInt(str);
  cout<<"number = "<<num<<endl;
  return 0;
}

int ascToInt(const char *ch){
  int out;
  int calc;
  
  out = 0;
  calc = 1;
  while (((*ch) == '+') || ((*ch) == '-')){  //checking the sign
    if (*ch == '-') calc = calc * -1; //if negative
    ch++;
  }
  do{ //converting char by char
    out = (out * 10) + ((*ch) - '0'); //substracting 48 to get the real number
    ch++;
  }while((*ch <= '9') && (*ch >= '0'));  //checking if it’s a number
  
  return (out * calc);
}

</num<

Advertisements

This program concatenates n amounts of strings, so in the output the user will see one long string.

https://github.com/admix/admixSoft/blob/master/OOP344/nstrcat.cpp

#include 
#include 
using namespace std;const char* nstrcat(char* to, ...);
int main(){  //Sample main() to test the program
    char str[100] = "";
    char first[] = "Space";
    char second[] = "Explorer";
    cout&lt;&lt;nstrcat(str, first, " ", second, " HeeHaw", '')&lt;&lt;endl;
    return 0;
}
const char* nstrcat( char* to, ...){
  char* inTo;
  int i = 0;
  va_list varg;
  va_start(varg, to);
  inTo = va_arg(varg, char*);
  while(*to)to++;
  while(inTo &amp;&amp; *inTo){	//returns '1' if true
  	while(*inTo){
  		to[i] = *inTo;
  		i++;         //keep going through the arguments
  		inTo++;
  	}
  	inTo = va_arg(varg, char*);
  }
  va_end(varg);
  return to;
}

There is a reason for what ever happens in your life…you’ll get it afterwords…just stay calm and clever for a while…

It’s better not to make fast decisions, not to be in a hurry, not to say simple and bad words to your friends, relatives and second halves… Life is a really very complicated thing, that has it’s own soul and vision. No one knows what could happened next, in ten years, in two years, even tomorrow…

Some people say that there are human beings, who knows the future, who can predict it, I’m not sure (to be honest), if they exist or not… I think I’ll believe only if I meet someone one day.

So the point is that people, we are, must not give up, we MUST, be in action every moment, we MUST do something, something that could be helpful for everyone, we MUST make difference and support each other…

Just some thoughts inside my head…//cc.admix

Here we go…

Posted: May 30, 2013 in Uncategorized
Tags:

Decided to start/move my blog to the WordPress πŸ˜‰ Will see how it goes here…