prushik 50 Junior Poster

Ok, well lets take a quick look at your original code. I have quoted your original post because it includes the full code and your original post where you gave some good example values. Your full post is below:

Hi there,
Kindly see my attached code below. This is already running however, I do have a little problem with the WITHDRAWAL part.

For example:
My current balance is 500 and I withdraw 501. It will tell me at first that I have insufficient funds and would prompt me to enter another amount. However, If I enter 501. It will tell me that I have -1 as my New balance which should't be. What I want is it will keep me prompting an mount either less than or equal to my current balance so that it will not display a negative new balance.

#include <stdio.h>
#include <stdlib.h>
int dep=0,ab=0,wdraw=0;
void acctbal()
{
	printf ("\n\n---Account Balance---\n\n");
	printf ("\n\nYour Current Balance is: %d\n\n",ab);
}
void deposit ()
{
	printf ("\n\n---Deposit---\n\n");
	printf ("Enter Amount     :");
	scanf ("%d",&dep);
	ab=ab+dep;
	printf ("\n\nAmount deposited: %d",dep);
	printf ("\nNew Balance: %d\n\n",ab);
}
void withdraw ()
{
	if (ab==0)
	{
		system("ds");
		printf ("\n\nplease be reminded that your current balance is: %d\n", ab);
		return;
	}
	else
	{
		printf ("\n\n--Withdraw--\n\n");
		printf ("Enter Amount :");
		scanf ("%d", &wdraw);
	}
	if (ab>=wdraw)
	{
		ab=ab-wdraw;
		printf ("\n\nAmount withdraw: %d",wdraw);
		printf ("\nNew balance: %d\n\n", ab);
	}
	else
	{
		printf ("\n\n Insufficient Funds--\n");
		printf ("please be reminded that your current balance is: %d\n",ab);
		printf …
prushik 50 Junior Poster

Yeah, it is one of the exercises given...I have my solution to code below but still trying to figure out the problem with the code above...Here is my complete code to the working one:

#include <stdio.h>
int d, w, cb, trans,res;

Deposit()
{
	printf("\nYour current balance is %d\n",cb);
	printf("\nPlease enter amount to be deposited:");
	scanf("%d",&d);
	cb+=d;
	printf("\nYou have successfully deposit to your account!!!");
	printf ("\nYour previous balance is %d\n", cb-d);
	printf("\nYour current balance is %d\n",cb);
	return(0);
}

Withdraw()
{
n:
	if(cb>0)
	{
		printf("\nEnter Withdraw Amount:");
		scanf("%d",&w);

		if(w>cb)
		{
			printf("\nSorry!You have Entered an Insufficient amount!\n");
			printf("\nPlease Enter another Amount.\n");
			goto n;
		}
		else
		{
			cb-=w;
			printf("\nYou have succesfully withdraw"); 
			printf("\nYour New Balance is :%d\n",cb);
		}
	}
	else
	{
		printf("\nYou do not have any money moron.\n");
	}
		
	return(0);
}

Inquiry()
{
	printf("\nYour Current Balance is:%d\n\n",cb);
	return(0);
}


void main()
{
start:
	printf ("\n*************Welcome to LBC Easy Banking System*************\n");
	printf("\n\n************* M E N U *************\n\n");
	printf("[1]-Deposit\n[2]-Withdraw\n[3]-Account Balance\n\n");
	printf("Enter Your Transaction type:");
	scanf("%d",& trans);

	if(trans==1)
	{
		Deposit();
	}
	else if(trans==2)
	{
		Withdraw();
	}
	else if(trans==3)
	{
		Inquiry();
	}
	else
	{
		printf("\nYour have entered the wrong code.\n");
		printf("Please try again!!!\n");
		goto start;
	}
	


	printf("\nDo you want to continue[1]-Yes [2]-No:");
	scanf("%d",&res);
	
	if(res==1)
	{
	
		goto start;
	}
	else 
	{
		printf("\nThank you for banking with us. Have a nice day!\n\n\n");
		
	}
}

That is essentially what I suggested, except with a goto statement instead of recursion. I personally never use goto in C because it can make your code look sloppy and hard to follow.
If you …

prushik 50 Junior Poster

I do not know how to do that actually. I'm so sorry.

Well, its pretty simple. Just call withdraw() again. Something like this:

if (ab>=wdraw)
{
ab=ab-wdraw;
printf ("\n\nAmount withdraw: %d",wdraw);
printf ("\nNew balance: %d\n\n", ab);
}
else
{
withdraw();
}

You see, in my example, if you try to withdraw too much, then it goes back to the beginning of the withdraw() function.
I'm assuming this is a homework assignment. You may not have learned recursion yet in your class, its very useful. However, if your teacher/professor does not allow you to use concepts that you haven't learned yet, you may need to look for an alternate answer. If that is the case, think about something like a while loop, a for loop could also work, but the syntax would look a little silly. If this is not homework, then I recommend recursion, as that is the cleanest way to do it. If you have learned recursion before, use it, professors love students that use recursion.

prushik 50 Junior Poster

fscanf(fp,"%*[^$]$%*[^$]$%*[^$]$%*[^$]$%d",&number)

How is that "just plain stupid"? It looks fine to me. Of course, there are other ways to do it, but fscanf would work just fine.

prushik 50 Junior Poster

Instead of asking for input again inside your function, you should print out a message (insufficient funds) and then call your withdraw function again recursively. Then the second prompt is identical to the first.

prushik 50 Junior Poster

letting gcc do all the work doesn't make the process less complicated, it just hides it from me. That the reason I use linux in the first place, because I want to know whats going on. I want to know everything thats getting linked in to my executable. Thanks for the info

prushik 50 Junior Poster

If you want to see what's happening, then do gcc -v -o hello hello.c It will print out the full command lines generated for the compiler, assembler and linker.

If you really wanted to, you could do the same things yourself. But doing so is highly specific to your current setup (which is why the recipe you followed on the site you referenced didn't quite work for you).

Well I tried that, I guess I didn't look at the output close enough, I didn't think that it was what I wanted. I ran it again, and I can see where it calls cc and as but it never calls ld. At the end of the process it calls a program called collect2, which seems to be the same as ld. I am not sure why its called collect2 instead. Is collect2 my linker?

/usr/lib/gcc/x86_64-linux-gnu/4.3.3/collect2 --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../.. /tmp/ccaeIJt4.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.3.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.3.3/../../../../lib/crtn.o
prushik 50 Junior Poster

Nobody has really answered my question. Banfa was the closest.
Maybe I didn't make myself clear before. I know how to compile c source code. I know I can just call "gcc hello.c -o hello" and end up with a working executable. However, that is not what I want. I want to know exactly all the little things that "gcc hello.c -o hello" does, and I want to be able to do all those little things myself. I want to call "cpp", "cc", "as", and "ld" separately so I understand the process completely.

prushik 50 Junior Poster

Hello everyone
I am trying to learn about the compilation process. I am working on a pretty simple SDL game, but I know that making games isn't very practical, so I am using the project to learn about other programming aspects as well. One of the things I am trying to learn about it the full compilation process, in detail. I have found an interesting article on the subject at: http://www.lisha.ufsc.br/teaching/os/exercise/hello.html
However, I followed the same steps the author of the article did, and I am having a lot of trouble in the linking stage. When I do the same thing the author did, I end up with a lot of undefined reference errors. If I link without the -static flag, it looks like it works, but when I try to run the executable, I get the error bash: ./hello: No such file or directory (which is not true, I can confirm that it exists and has the correct permissions with "file" and "ls -lA"). I thought that maybe the issue was my 64 bit processor and I was linking against some 32-bit libs, so I tried linking against libs from /usr/lib64/ instead on /usr/lib/ but the result was the same.
If I can't get this simple "hello world" code to build correctly, my game certainly won't. What am I missing?
I am using linux and gcc, if that isn't obvious.
gcc version 4.3.3

prushik 50 Junior Poster

I doubt it, the server is configured to return a 5. And plus, it works like over 99% of the time. The packet structure is always the same, so I dont think that could be the problem, unless of course something is wrong on the server and its resending the last message which gets parsed wrong or not parsed and an uninitialized variable gets passed to sleep(). but that would only cause my program to block, all other processes in the device lock up too.
Also, I personally never call alarm() or longjmp(), and definitely never at the same time as sleep, my program is not multi-threaded, so thats pretty much out of the question. I have no idea what other processes are doing though. There shouldnt be much else running, but the programs that are running at the same time were written by the engineering department, so I have no clue what they are doing. also, I'm not sure if it would be an issue even if another process called one of those functions.

prushik 50 Junior Poster

I have written a program for a linux box running on a davinci (arm processor). The program communicates with a server over the lan, calls some scripts, and delays different amounts of time depending on what the server tells it to do. It all works great, most of the time. every once in a while though, (2% of the machines, once every 16 hours) will freeze at the delay command.

sleep(DisplayDuration);

DisplayDuration is an int

It seems when this happens, the command isnt just blocking, the whole phone locks up. Does not respond to pings, does not respond to serial input. It must be power cycled to recover.
Has anyone else seen this? The percentage is very low, but its too high for production, and we need to know if this is a software problem that we can fix or a genuine hardware failure.

So, what I'm asking is: is there something wrong with the C function "sleep(int)" in linux? Has anyone else experienced a device freezing when calling this function? can someone explain why this happens, or suggest a solution?

Thanks.

prushik 50 Junior Poster

why not just use:

printf("Input hexadecimal number: ");
int hex;
scanf("%x",hex);

Seems easiest to me, then it gets stored as an int. you can display it as a hex or a decimal: printf("%X",hex) Hex printf("%d",hex) Decimal

prushik 50 Junior Poster

http://beej.us/guide/bgnet/output/html/multipage/syscalls.html#bind

Since your port is <1024, are you running as root?

Some more error checking wouldn't go amiss either. You might have found the error to be "EPERM" or something.

I am running the executable as root, so its not a permissions issue.

Yes, I am running as root. sudo ./tftps I'm thinking maybe something else is using that port, but I uninstalled all other tftp severs, and I see no other traffic on wireshark.
Meanwhile, i'll add some more error checking. I have a tendency to use printf for all debugging.

prushik 50 Junior Poster

I am trying to write a TFTP server. I have successfully completed the code, it is fully RFC 1350 compliant.
However, I wrote the whole thing in Haiku OS, and in Haiku, it works great. However, I also need a DHCP server, and I don't have one for Haiku. So I need to port my TFTP server to Linux.
Now the code compiles fine in linux, but does not receive any packets sent to it. I can do wireshark captures and see that the packets are arriving, but my server does not receive them. I added some debugging printfs and found that bind is returning a -1 (instead of 0 like in Haiku). I am running the executable as root, so its not a permissions issue. Am I doing something wrong? Here is some of my code:

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
int sock, length, n;
struct sockaddr_in server;
struct hostent *hp;
unsigned char buffer[1024];

//Set up and open datagram socket
sock=socket(AF_INET, SOCK_DGRAM, 0);

//Setup socket properties
server.sin_family = AF_INET;
server.sin_addr.s_addr=INADDR_ANY;
server.sin_port = htons(69);

length = sizeof(struct sockaddr_in);

n=bind(sock,(struct sockaddr *)&server,length);
//Finish setting up datagram socket. It should be open.

printf("%d\n",n);

So where did I go wrong?

prushik 50 Junior Poster

Ok, I tried that. No difference.

prushik 50 Junior Poster

I'll give it a shot. But shouldn't apt have done that automatically when I removed and reinstalled it?

prushik 50 Junior Poster

I did try that, but ended up with an empty log file.

I resized my windows partition (Non-Destructively!!! Yay!) and made a new ext4 partition (is there a reason I shouldn't use ext4? My old system was on an ext3). So I'm going to install a brand new system, mount my old one, copy my configs and files (the ones that I want), and then extend the ext4 partition. I didn't really want to do that, but I want my computer to work right again, and windows is bugging me. Plus, installing new systems is fun! I'm going to start from scratch, compile my own kernel and such. Should be fun.

Thanks anyway for the help, sorry to be a bother

prushik 50 Junior Poster

Yes that's true. That's pretty much what I was trying to say. If it doesn't work its most likely because you need admin privileges.

prushik 50 Junior Poster

I have seen it not work on some machines. In high school i tried it on the school PCs and it wouldn't work (I messed with my friends in that class all the time). So if OminiX can't get that to work his user account may not have the necessary permissions.
If it does work for OminiX then the other suggestions may not have worked because of something in the registry blocking shutdowns. If that is the issue, another (better) solution could be implemented.

prushik 50 Junior Poster

in the terminal:
"sudo dhclient" will DHCP for you.
"ifconfig" will display all of your network interfaces (and their IP addresses)

prushik 50 Junior Poster

try using system("shutdown -s -f -t 00");
Its not the best solution, but whether it works or not, it will be informative.

Ancient Dragon commented: good solution :) +36
prushik 50 Junior Poster

I couldnt imagine permissions causing that issue, but the fact that they are all in the same folder makes me think that. Check the permissions on those folders.

prushik 50 Junior Poster

My Xorg.0.log:

X.Org X Server 1.5.2
Release Date: 10 October 2008
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.24-19-server i686 Ubuntu
Current Operating System: Linux prushik-laptop 2.6.28 #2 SMP Mon Mar 2 22:27:50 EST 2009 i686
Build Date: 24 October 2008  08:00:16AM
xorg-server 2:1.5.2-2ubuntu3 (buildd@rothera.buildd) 
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Module Loader present
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri Mar 20 21:46:51 2009
(==) Using config file: "/etc/X11/xorg.conf"
(==) No Layout section.  Using the first Screen section.
(**) |-->Screen "Default Screen" (0)
(**) |   |-->Monitor "Configured Monitor"
(**) |   |-->Device "Configured Video Device"
(==) Automatically adding devices
(==) Automatically enabling devices
(==) No FontPath specified.  Using compiled-in default.
(==) FontPath set to:
	/usr/share/fonts/X11/misc,
	/usr/share/fonts/X11/cyrillic,
	/usr/share/fonts/X11/100dpi/:unscaled,
	/usr/share/fonts/X11/75dpi/:unscaled,
	/usr/share/fonts/X11/Type1,
	/usr/share/fonts/X11/100dpi,
	/usr/share/fonts/X11/75dpi,
	/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType
(==) ModulePath set to "/usr/lib/xorg/modules"
(II) Cannot locate a core pointer device.
(II) Cannot locate a core keyboard device.
(II) The server relies on HAL to provide the list of input devices.
	If no devices become available, reconfigure HAL or disable AllowEmptyInput.
(II) Open ACPI successful (/var/run/acpid.socket)
(II) Loader magic: 0x81d9a40
(II) Module ABI versions:
	X.Org ANSI C Emulation: 0.4
	X.Org Video Driver: 4.1
	X.Org XInput driver : 2.1
	X.Org Server Extension : 1.1
	X.Org Font Renderer : 0.6
(II) Loader running on linux
(--) using VT number 7 …
prushik 50 Junior Poster

I typed a big ol' response before I rebooted and I swear I hit post. But I guess I failed at that too. I'm really striking out today.
Anyways. I took a look at those files, xorg.conf looked fine and I restored my old one (that worked) and nothing changed, figures. I looked at the log file and didn't see any errors (EE). However, there were some warnings (WW) and notices (!!). I'll post the file, maybe you will see something I don't.

prushik 50 Junior Poster

I'll switch to linux and take a look at those two files. I think I may incidentally have a few backups of my xorg.conf file, so it would be a treat if that were the issue (I may not have them). It would make sense since I only used remove/install instead of purge/install. I suspect the issue is worse than that though, but I could be wrong.
I'll look as soon as I get off the phone.

prushik 50 Junior Poster

I recently decided to take a chance and install some unstable upgrades (I love unstable things). So I upgraded many of my applications via apt-get. One of the big things I upgraded was libc6. I think that my be the issue, not sure. After the upgrades, I had many many problems. I was able to fix nearly all of them in different ways, many by downgrading, others by changing permissions (somehow root stole my home folder and made it read-only to regular users). However, one issue still remains: gnome will not start. X was upgraded, but I removed and reinstalled a stable version. When I run 'startx' I get an X display (checkerboard) with the pointer in the middle. I can not move the pointer and no windows manager loads. If I run "startx gnome-session" or "startx gdm" or "xinit /usr/bin/gnome-session" the screen flashes and I am returned to the console. any X errors are already off the screen by the time I get back to the console, and i couldnt redirect the output to a file for some reason.
I tried reinstalling x, gnome, gdm, and xterm, but it didnt help. Also, i tried to downgrade libc6 and it wanted to remove coreutils and apt and other very important packages. So I havent done that.
Any advice?
Thanks in advance everybody, I feel pretty dumb right now, I'd like to get this working again.

prushik 50 Junior Poster

date is normally in /bin/ instead of /usr/bin/

prushik 50 Junior Poster

or you can give full paths in your script.
e.g.
/usr/bin/less instead of less

I'm sure you don't use less, but its an example

the best thing to do is set the environment variables in your script, like masijade said:

PATH=$PATH:/usr/bin:/usr/sbin:/sbin

prushik 50 Junior Poster

Oh yes. I am sorry. I forgot to mention that I did try that (sudo test) and the result was identical.
I found the solution by the way. However I am still puzzled.
It seems that == is accepted and works correctly as a normal user, but as superuser, only = works and == returns an error.
My fault for using c++ syntax instead of bash. However, I am very puzzled as to why this only returns an error when using sudo. Also, I logged in as root and no errors were returned. So this only occurs when using sudo. Why does this happen, I don't know enough about sudo to understand this issue, but I would love to learn.

prushik 50 Junior Poster

I wrote a shell script that checks the command line arguments for the "-i" flag.
I designed it to run from inside my gui application.
I tested my script from the terminal and it runs perfectly, does just what I want and expect. So I ran my gui (which needs superuser) and my gui would not run correctly. So I ran my gui from the terminal to see its output and saw a plethora of errors from my script (output at bottom of post).
I couldn't find a problem with my script, so I tried breaking it down to diagnose the problem. I found that when I ran my script as superuser it returned errors. So I tried just running the error line of my script as superuser and it returned the same error. And I can not figure out why.

The problem line is:
if [ "$x" == "-i" ]

To reproduce the error, run:
[ "-i" == "-i" ] ; echo $?
and
sudo [ "-i" == "-i" ] ; echo $?
the second will produce an error.

[: 34: ==: unexpected operator
[: 34: -i: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: -i: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator

I just cant figure it out

prushik 50 Junior Poster

Ok, I found the problem. The problem was that my near clipping plane was too close to the viewer. gluPerspective(45,1,0.01,1) where before it was around 0.0001. I discovered this because I noticed that depth testing WAS working in some parts but not in others.

jephthah commented: thanks for coming back and giving an update on that! :) +3
prushik 50 Junior Poster

Well, my laptop is a couple of years old, and the other machines are more than a couple years old. So I'm sure the info you are drawing from is valid.
You are probably more informed than I am, thanks for the help.

prushik 50 Junior Poster

Ok, that explanation would make sense. I thought depth testing was all software though. The computer that it runs best on is my laptop, which just has what could be considered a "gaming" video card. Its a decent card, not the best, not anymore at least, but even so, none of the other video cards on the other machines would even compare to it, so that's a plausible explanation. Thanks. I'll look into it.

prushik 50 Junior Poster

All the machines are Windows XP. Although some are kind of older computers. Non-gaming/work computers. Thats why I'm thinking its a version issue.

prushik 50 Junior Poster

I'm not trying to distribute it. just test it. and i have actually compiled it from source on other machines, its the same problem.

prushik 50 Junior Poster

I have written a few games in C++ with OpenGL, and I am working on another one now, its my biggest project. Everything works really great on my computer, but whenever I move my executable to another computer, the depth testing completely stops working.
I have no idea what causes this problem, my code works great on my pc, so I don't know what the problem is on other pcs. Is this a problem with the version of OpenGL I am using? That's all I can think of. Has anyone else seen this before?

prushik 50 Junior Poster

Ok, thank you very very much. That was what I needed to know. I don't like the nested for loops, but it will work.

prushik 50 Junior Poster

Basically I want to set up a 3-dimensional array, but I want to dynamically allocate memory for it.

Say I read 3 variables from a file, all ints:
f, s, and v.
i want to allocate memory for
array[f][s][v]

array is part of a struct

How would I go about doing this?

I did search google, but only came up with solutions for 1D arrays

prushik 50 Junior Poster

you need an input statement inside your while loop.
Take the break statement out, it was an infinite loop because score can never = -999 because score never changes inside the loop.

prushik 50 Junior Poster

Win API

I'm sorry, I should have mentioned that.

Windows XP
Bloodshed Dev-C++

prushik 50 Junior Poster

I will say that do not use c++ , its a good language but not as good as asp or java ... use them the game will looks great....3 d

Do not listen to that advice. Java in my experience (BOTH programming and using programs developed in java) really bites. Speed is a huge issue with Java, I know people say its just as fast as anything else.... that is very far from true, if you want proof, compare speeds of programs developed in Java with similar programs developed in C++. Don't know much about asp, but I wouldn't recommend it. And I am also no a C# fan, it has many of the same flaws as Java.
I hear people complain about C++ pointers and memory allocations, but its really not that hard, people are just lazy.

My recommendation: C++ all the way

Plus, C++ is the most respectable to most people

prushik 50 Junior Poster

What is the easiest way to get a user input string (char array) from within an OpenGL program? It doesn't have to look good, this is just for debugging purposes.
Thanks.

prushik 50 Junior Poster

You could generate valid c++ code that does a few couts to display the text and then output that to a text file and use system() with a command line compiler to compile it into an exe.

Oh, by the way, I know it was my suggestion, but I should tell you that it would be very bad programming practice.

prushik 50 Junior Poster

You could generate valid c++ code that does a few couts to display the text and then output that to a text file and use system() with a command line compiler to compile it into an exe.

prushik 50 Junior Poster

ok, here is my problem.

I am using sprintf to write a formatted string. That works fine.
it looks like this:

sprintf(buffer, "%f,%f,%i,%f,%f", user.x, user.y, user.dir, user.xspeed, user.yspeed);

where user is a struct
x is a float
y is a float
dir is a short int
xspeed is a float
yspeed is a float

I am parsing the exact same string using sscanf. And I end up with some crazy values.

sscanf(buffer, "%f,%f,%i,%f,%f", &remote.x, &remote.y, &remote.dir, &remote.xspeed, &remote.yspeed);

remote is another member of the same struct as user
x is never right
y is never right
dir is the only one that works i assume it has to do with the fact that it is the only int
xspeed I haven't even tested
yspeed is the same deal as xspeed


Why does this happen? I see no reason for it to not work

prushik 50 Junior Poster

If you still want it to pause so you can see the output, use cin.get();

prushik 50 Junior Poster

Take out the system("PAUSE"); line at the end.

prushik 50 Junior Poster

Very simple, 1 line solution.
Make a boolean variable called pause:

pause = !pause;
prushik 50 Junior Poster

WSAGetLastError() always returns 0. which is nothing.

prushik 50 Junior Poster

I am using bloodshed dev-c++ ide. Win XP Media Center Edition.
I am trying to learn how to use winsock, I have compiled a very simple (and very sloppy) little winsock application with the help of like 3 or 4 different tutorials
the client sends a hard coded string to the server at my loopback address (127.0.0.1). the server receives the string
that all works, I can get the string and display it on the screen. However, the recv() function always returns -1 (error) instead of the expected number of bytes received. Why does this happen? It doesn't make sense because I do actually receive the string. I am stumped.