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
*/

Perfect i love you :d

That would be ASCII, not ANSI ;)

you can mark the thread solved now.

As they say, ASCII stupid question, get a stupid ANSI ;)

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

std::cout << "text[0] = " << (int)text[0] << '\n';

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];
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.