Just thought id post here while i search google at the same time because well two brains are better than one :)

The Asc function converts the first letter in a string to ANSI code, and returns the result.
Syntax

Asc(string)

Thats the VB version of it, i need something similar in c++
ok back to searching google

Like this?

#include <iostream>

int main()
{
   char text[] = "hello world";
   std::cout << "text = \"" << text << "\"\n";
   std::cout << "text[0] = '" << text[0] << "'\n";
   std::cout << "text[0] = " << static_cast<int>(text[0]) << '\n';
   int value = text[0];
   std::cout << "value = " << value << '\n';
   return 0;
}

/* my output
text = "hello world"
text[0] = 'h'
text[0] = 104
value = 104
*/

Well i needed a function for this so i made

#include <iostream>

int Crypt(char szChar[]);

int main()
{
   char text[256];

   printf("Enter a string: ");
   scanf("%s", text);
   
   int final = Crypt(text);

   printf("value = %d \n\n", final);

   system("PAUSE");

   return 0;
}

// Credits to Dave Sinkula - Daniweb.com
int Crypt(char szChar[])
{
	int value = static_cast<int>(szChar[0]);
	return value;
}

incase anyone else needs it lol

haha, you use standard C code for the first part then a C++-style cast for the function. You should just make it C,

int Crypt(char *szChar)
{
return (int)szChar[0];
}
This question has already been answered. Start a new discussion instead.