hi there,
I have been struggling for a while with a client/server program. I have to authenticate in order to log on correctly. I have managed to get most things sorted, asking for username ( which is an integer ) and also and customer ID (also an int), storing them into an array and then sending the data over to my server. However when if I printf the data the on the server the numbers do not match, and I do not know why ?
Somebody said that i needed to convert my integers into strings in my client program before sending them to the server....how on earth do i do this ? Do i need to do it ?
I have tried looking through google but have been unable to find anything on this subject, anyone got any ideas ?
Thanks for reading !
4 1536
hi there,
I have been struggling for a while with a client/server program. I have to authenticate in order to log on correctly. I have managed to get most things sorted, asking for username ( which is an integer ) and also and customer ID (also an int), storing them into an array and then sending the data over to my server. However when if I printf the data the on the server the numbers do not match, and I do not know why ?
Somebody said that i needed to convert my integers into strings in my client program before sending them to the server....how on earth do i do this ? Do i need to do it ?
I have tried looking through google but have been unable to find anything on this subject, anyone got any ideas ?
Thanks for reading !
Function itoa converts int to string.Function syntax is: char *itoa(int value, char *string, int radix);
where:
value - integer to be converted
string - points to location where converted number and terminating \0 are stored
radix - specifes the base used in converting value.Base isnumber beetwen 2-36,inclusive
Ok but what happens when i type in a long integer can i put an array name where value should be ?
i.e
char *itoa(int customer id[], char *string, int radix);
Ok but what happens when i type in a long integer can i put an array name where value should be ?
i.e
char *itoa(int customer id[], char *string, int radix);
Yes,you can.Only posible problem is that you must use a loop.
Here's a small example: - int main(void)
-
{
-
int number[5],i;
-
char *string[25];
-
clrscr();
-
for(i=0;i<5;i++) number[i]=0,*string[i]='\0';
-
for(i=0;i<5;i++) number[i]=1+i;
-
for(i=0;i<5;i++)
-
{
-
itoa(number[i], string[i], 10);
-
*string[i-1]='\0';
-
printf("integer = %d string = %s\n", number[i], string[i]);
-
}
-
getch();
-
return 0;
}
is the representation of integers on the client and server machines the same? i.e. number of bytes used to store an int and if they are big endian or little endian. If not you will have to transalate between the representations.
If you have less than 256 user codes you could use an unsigned char (which is a byte sized integer) to store the value.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Peter Warder |
last post by:
I'm still struggling with these conversions! The wider code is working well
but I can't get the compiler to accept my attempts at converting Integers
(back) into Strings.
What's the trick?
...
|
by: Hugo Amselschlag |
last post by:
Hi there,
I've implemented a local system hook to suppress certain windows beeing
displayed by the axWebbrowser control. Now I need some more information
before I can decide, whether to suppress...
|
by: TomServo |
last post by:
I am writing code that needs to run on a variety of Unix systems. I am
calling the statvfs and statfs system calls and I need to to convert some of
the integers returned to character strings....
|
by: CoreyWhite |
last post by:
Problem:
You have numbers in string format, but you need to convert them to a
numeric type, such as an int or float.
Solution:
You can do this with the standard library functions. The...
|
by: jimmypringles |
last post by:
Anyone knows how how to add "number" strings without converting them to integers?
I came up with this function but it didn't work perfectly.
e.g. I added "1998" and "8991" and the result was...
|
by: Jeff |
last post by:
....still new to vb.net 2005
I understand the concept of arrays, and have used them in other languages,
but was hoping that someone could get me started with something.
I have a fairly long...
|
by: py_genetic |
last post by:
Hello,
I'm importing large text files of data using csv. I would like to add
some more auto sensing abilities. I'm considing sampling the data
file and doing some fuzzy logic scoring on the...
|
by: HONOREDANCESTOR |
last post by:
I've been converting a dotnet dll to a com object so that it can be
called from vb6. If I want to pass a structure to a routine in the
com object, like this:
Call MyRoutine(byref MyStruct as...
|
by: andrews |
last post by:
I try to add strings with fixed length who are representing integers
So I have to put spaces (I guesse) before short strings(from short
integers).
F.e.
12345
1
567
5432
54328
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |