jephthah 1,888 Posting Maven

that's dumb.

what if he wants to add 9999 as one of his numbers

jephthah 1,888 Posting Maven

Commodore PET.

oh gawd, i remember that. my first computer book was "Programming the PET"... i think i still have it somewhere at my folks' house.

jephthah 1,888 Posting Maven

Look i am no expert but if really want to improve your communication skills , you should work on your knowledge

that's about the most insensitive, presumptuous, short-sighted, arrogant and prejudiced remark i've heard in probably... well ... probably a day or two.

i mean, the internet has desensitized me, but still.

stfu.

jephthah 1,888 Posting Maven

this is C. "bool" types are not allowed. neither are you allowed to declare variables within a for loop's conditional statement. the fact that you are able to get away with it using a C++ compiler doesn't matter. standard C compilers this fails to compile\

that said, ive gone ahead and changed bool to int, ive replaced true and false with 1 and 0, and ive properly declared your index variables i and j outside the for conditional.

now the program compiles but doesnt do anything, just sits there blankly.

what was your question anyhow?

if you want help troubleshooting you need to post compilable code with a definite question about some behavior that can be reproduced. if it's not apparent on how to reproduce the problem, then you need to explain to us how to get where you are.

as in this case: i have no idea how this program should work. maybe i could spend my time trying to figure it out ... but i'm not going to.

jephthah 1,888 Posting Maven

this is retarded.

you won't get a reading from the free electrons in the air. you'll get a reading from the noise of the instrumentation pathway, which is deterministic.

now, i'm glad you're the hero of this 13-year-old's fantastical musings, but really, you ought to take your own advice about "spending your time on other things."

jephthah 1,888 Posting Maven

No.

And no.

jephthah 1,888 Posting Maven

An example of this blah blah blah at any given point using some sort of analog device

or maybe you could sprinkle some magic fairy dust, and use some "sort of analog device" to aggregate the quantum velocities of the fairies at any given point according to Heisenfairy's Uncertainty Principle.

or you could just say fook it, and thow Schroedinger's cat into a lorenz attractor and save yourself a fair bit of math/sonic calculating, and call it 50/50.

:icon_rolleyes:


.

jephthah 1,888 Posting Maven

no worries. glad it's working out for you.

For the record, "atoi()" has a problem that you can't telll the difference between an error (failure) and reading a valid zero (0).

"strtol()" is preferred. probably won't matter to you now, but someday it might.

jephthah 1,888 Posting Maven

NO .... atol and strtol are not C++... they are part of the standard C library, <stdlib.h>.... understand that C++ is a "superset" of C. most everything in C is also in C++

so you dont have to manually convert each digit. I thought your variable was a single character, and that would have been the most simple way.

do feel free to go ahead and roll your own string-to-numeric converter if you like, there are worse things you could do, i suppose. but when you get tired of undefined behavior due to loosely written code, remember that a validated function is already available to you.


.

jephthah 1,888 Posting Maven

okay... i thought 'strVal' was a single character.... so, no you dont have to convert each character and multiply by the power of 10. that's the long way. use the standard libraries instead.

such as the function "atol()" (Ascii TO Long integer) or "strtol()" (STRing TO Long integer) ... either will convert a string to its numeric (integer) value

of course, Unsigned Long Max is 4294967295, so it would be meaningless for your strVal to have a length of more than 11 characters.

.

jephthah 1,888 Posting Maven

o wait. did you say strVal is a 1024 lenght character array??

that doesnt make sense....

how, exactly, is strVal defined?

jephthah 1,888 Posting Maven

seemingly random

there's your problem: nothing is truly random. some things are just less predictable than others.

the fact is, you're never goign to generate truly random numbers, even if something like that existed. so be happy with the commercially available pseudo-random number generators, like the rest of the world.

if you're doing something that needs more than that, then you're working for the NSA and shouldnt be trolling Daniweb for your answers.

tux4life commented: You're absolutely right :) ! +3
jephthah 1,888 Posting Maven

is strval a single char that is a numeral character between 0 - 9?

then you cant just recast it as an int.

to convert a character numeral to it's integer value, you have to subtract 0x30 (decimal 48) from the character (ascii) value. int value = (int)strVal - 48;

jephthah 1,888 Posting Maven

there are over 39,000 people in the U.S. with my real name.

there are 1 or fewer people in the U.S. with my screen name.

jephthah 1,888 Posting Maven

this assignment has never been given before!!!!11

jephthah 1,888 Posting Maven

i call shenanigans.

this scheme assumes every city with a population this side of Irvine, CA (pop ~201,000) will be completely devastated.

anyhow, the 1980's called: they want their mass scare back.

:P


.

jephthah 1,888 Posting Maven

Once the duration expires, the member is automatically unbanned and can start posting again. I think that this pretty much serves as a decent "rehabilitation" measure.

oh, i see. i didnt understand that. yes, that is quite the same concept.

so never mind :)

jephthah 1,888 Posting Maven

>>not true. MD5 is broken.

This is true that MD5 has been broken. I heard this news long before.

I'm happy to hear you are so well-informed.

so now there's no reason for you to continue promoting MD5 as an algorithm that produces unique hash values, yes?

OK, but it's just really difficult how to do it, a normal PC-user will never manage to break this algorithm

what a terribly fatal assumption! are you telling me a skript kiddie can't read a published algorithm and implement it on a $200 laptop?

"security through obscurity" is no security at all.


.

jephthah 1,888 Posting Maven

And if two files are different, their md5sum hash will of course be different.

not true. MD5 is broken.

in 2004, Wang et. al. demonstrated that forced MD5 collisions could be generated; in December 2008 the Chaos Communication Group forged an SSL certificate using forced MD5 collisions, in March 2009, Kilma published an algorithm that will force an MD5 collision using a single computer in less than one minute.

jephthah 1,888 Posting Maven

what about an option to "rehabilitate" a banned member who wanted another chance?

like a one-chance sort of thing where you're in probationary status, repeat offense would be irrevocable?

i guess that would redefine "ban" into something more like a suspension, though.

eh, probably not a good idea; just throwing it out as an option...

jephthah 1,888 Posting Maven

okay, someone added code tags for you.

for one thing, your program output is all messed up, even for one month at a time. it looks like you took the original code and made a stab at modifiyting it, then posted the broken result here?

i guess before we go any further, have you considered using the built-in calendar and date library C? its called <time.h> and chock full of useful stuff.

anyhow, if you're going to continue down this path the only way you can print multiple column of months is to calculate each of the month on any particular row at the same time. so you'll need multiple variables for each column. like "days_in_month1" and "days_in_month2"

i got kind of curious and wound up doing it myself. with three months in each row. you can see the output here as an example

jephthah 1,888 Posting Maven

yeah, i could probably help you with this, but unfortunately you didnt use code tags, so it's all but completely unreadable.

next time, try this:

[code=c] your code goes here

[/code]

jephthah 1,888 Posting Maven

a few things here, that i think are confusing:

the string you are sending, "GET /DATA.HTML /HTTP1.0", is kind of meaningless. by that i mean there is nothing in this string that affects the behavior of the server. the whole concept of "GET" is that it's a command that tells the server what to do. other commands would be "PUT" or "DEL(ETE)" or "CD" or "DIR" or "QUIT". likewise your "DATA.HTML" means this should also be parsed so that you choose one file from one or more possible files in the working directory.

another thing thats bothering me somewhat is the ubiquitous use of the variable "echoBuffer" for both sending and receiving. i suggest that you change your Server code for the "HandleTCPclient" function to use the concept of send and receive, and forget about this 'echo':

void HandleTCPClient(int clntSocket)
{
    char recvBuffer[RCVBUFSIZE];        /* Buffer for recv string */
    char sendBuffer[SNDBUFSIZE];        /* Buffer for send string */
    int recvMsgSize;                    /* Size of receive message */
    int sendMsgSize;                    /* Size of send message */

    /* Receive message from client */
    if ((recvMsgSize = recv(clntSocket, recvBuffer, RCVBUFSIZE, 0)) < 0)
        DieWithError("recv() failed");
        
    /* incoming request from client is in the recvBuffer */
    /* message can be parsed as necessary */
    printf("  received client message: %s\n",recvBuffer);
    
    /* put outgoing message from server in the sendBuffer */   
    sprintf(sendBuffer,"MOTOR=0,TEMPS are 3A,42,FA,99");   //reply! 
    sendMsgSize = strlen(sendBuffer);

    /* Send message until transmission completed*/
    while (recvMsgSize > 0)      /* zero indicates end of transmission */ …
jephthah 1,888 Posting Maven

tell me what is the entire point of the book?

tell me, what is the entire point of this thread?

besides being a means for some random internet guy to air out his creepy obsession for a female user, while simultaneously demonstrating that he doesn't know anything about programming.

because anyone that would either (a) take the 20-year-old Unix Hater's Handbook as being some sort of serious critique in favor of Windows, or (b) use it as evidence that C++ is a "horrible language" .... that person is a gotdam fool.

John A commented: damn straight +20
jephthah 1,888 Posting Maven

this program, i hate to tell you, has a number of problems. for instance, i cant even get past the "getInput" function. what is going on here?

while (userName[nameLenght] != 0){
		nameLenght++;
	}

	for(i = nameLenght; i > 0; i=i-1);{

		printf("username = %s\ni = %d\n\n\n\n",userName,nameLenght);


		userName[i + 3] = userName[i];
	} // end For loop

i'm not sure what you're trying to do, but the result is mangling the userName string. do you notice that you're writing BEYOND the end of the string!

another major problem I personally have, is that you are hardcoding the C:\ directory as the place to read and write?? i dont have a C:\ directory. you're assuming we all use windows... well, we don't. and even if i decided to go get on a windows machine, like my wife's laptop, the last thing I would want to do is let your program write to the root drive.

that is really a bad idea, generally speaking. you should instead read and write to a relative drive location determined by the working directory in which you execute the program.

as it stands right now there's little i can do to help you since I'll never be able to get this working on my machine without a significant rewrite.

jephthah 1,888 Posting Maven

another way to do it would be to capture the output of the "ls" or the "dir" command using popen() ...

i know this works for GCC on Linux, and i assume it will work for windows, but i don't know for certain. try replacing "dir /b" (or whatever variant you want to use) with the "ls" command.

#include <stdio.h>

#define LIST_COMMAND	"ls"

int main (void)
{
	char buffer[1024];
	char *line_p; 
	FILE *dirList_p;

	if (dirList_p = popen(LIST_COMMAND, "r")) 
	{
		while(line_p = fgets(buffer, sizeof(buffer), dirList_p))
			printf(buffer);
		pclose(dirList_p);
	}
	else 
		return -1;
		
	return 0;
}
jephthah 1,888 Posting Maven

theres no standard way to do this. it totally depends on your environment.

for instance, a POSIX solution might look like this

#include <stdio.h>
#include <dirent.h>

int main (void)
{
   DIR *dir_ptr;
   struct dirent *entry_ptr;

   if (dir_ptr = opendir ("./"))
   {
      while (entry_ptr = readdir (dir_ptr))
          printf("%s\n",entry_ptr->d_name);
      closedir (dir_ptr);
   }
   else
      printf ("Can not open directory\n");

   return 0;
}

while the Windows solution could be done with the API commands "FindFirstFile" and "FindNextFile"
http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx

jephthah 1,888 Posting Maven

just to start, i notice a couple things:

warning: return type of ‘main’ is not ‘int’

"void main" is wrong. don't do it.

warning: the `gets' function is dangerous and should not be used.

NEVER EVER USE GETS.

ever.

fix those things and we can move along.

jephthah 1,888 Posting Maven

looks like jbennet is scru's advocate, too.

it's a conspiracy, i say, a conspiracy.

jephthah 1,888 Posting Maven

ah... yes, you're right. i gave a 16bit value for a bitmask, when i meant to give a 32-bit value

the bitmasks should be 0x0000FFFF and 0xFFFF0000 , respectively

thanks for noticing.

sorry for the confusion

.

jephthah 1,888 Posting Maven

your for loop is confusing . instead of that convoluted decrement method you're trying to do, do something like this (pseudo code):

set team[0] <-- teamlist[userchoice]

set  counter  = 1
for loop = 1 to (total # of teams - 1)
     if loop = userchoice, do nothing
     else team[counter++] <-- teamlist[userchoice]

.

jephthah 1,888 Posting Maven

what makes you think you know better than i do?

the very fact that you made this thread?

jephthah 1,888 Posting Maven

no problem. any time.

jephthah 1,888 Posting Maven

Ok i got 3 errors now, and im using Boreland C++. Teacher made me declare the variables globally, as im going to be using it throughout the functions.

How curious... your teacher requires Borland complier and to globally defined variables.

tell me, what school do you go to?

jephthah 1,888 Posting Maven

I know how to isolate the 16bits on the 32bit instruction, by shitfting it 16bits left the shifting it 16bits right again.

that's not how you do it. AND it with a bitmask 0x00FF to get the lower 16 bits out of the instruction and copied into the destination register

But apparently i have to sign extend this number coz im adding to a 32 bit register which is the source register. Any ideas on how to do this? Very confused.

the MSB (bit 15) is the sign bit. If bit 15 == 1, then OR all ones into bits 16-31 using the bitmask 0xFF00 , otherwise leave it alone since it already has zeros there

jephthah 1,888 Posting Maven

He finally got to you... Oh well

i know. i should be better than that. :(

jephthah 1,888 Posting Maven

But now i get another error."incompatible types in assignment".

you cant use the assignment operator (=) to copy strings.

use "strcpy()" like you did earlier in the function.

or, better yet, use "strncpy()".

jephthah 1,888 Posting Maven

use "fopen()" to open the file, and specify "read, binary" as the mode.

FILE * fp;
fp = fopen("file.dat","rb");

note the following:

In the case of text files, depending on the environment where the application runs, some special character conversion may occur in input/output operations to adapt them to a system-specific text file format. In many environments, such as most UNIX-based systems, it makes no difference to open a file as a text file or a binary file; Both are treated exactly the same way, but differentiation is recommended for a better portability

--http://www.cplusplus.com/reference/clibrary/cstdio/fopen/

in other words, if you think the file has numeric values, read them the same way using fgets() or sscanf() or similar.


.

jephthah 1,888 Posting Maven

yeah, sorry, i dont know offhand where these sorts of resources are.

i think your written english is very good, by the way. to be honest, i would have thought it was your first language, by the way you write.

jephthah 1,888 Posting Maven

i figured how 2 solve q4 now but i tried 2 solve 1,2,3 i cant do anything .

bull crap.

you did not just spontaneously "figure out" how to write the code for Q4, and yet still remain completely helpless to even begin Q1 - Q3. because Q4 combines all the elements of programming that you would need to know for Q1 - Q3

what happened is, someone gave you the answer for Q4, or you found it on another site, and now you're still waiting for someone here to give you the rest of the answers.

until you show some of your work so far -- and ask a meaningful question -- you're just going to be ignored.


.

Salem commented: Damn straight. +29
jephthah 1,888 Posting Maven

aiight, dude. i'm tired of all this grabassery. here's standard c, that will actually work. I'm not going to bulletproof the input or conversion for you, but it's close enough for your needs, and better than what you had before:

#include <stdio.h>
#include <stdlib.h>

int main (void)
{

    char a[10];
    int sum=0, count=0, min, max, val;

    while(fgets(a,10,stdin))   // never use "gets()"
    {
        a[strcspn(a,"\n")]='\0';  //strip newline

        if(strlen(a)==0) //  dont loop input on feof() either
            break;

        val = atol(a); // standard library function 

        // and i hope to god you can finish this on your own
        // ...
        // ...
        // ...

   }

    printf( "Min: %d, Max: %d, Avg: %4.2f\n", min, max, (float)sum/count);

    return 0;
}

.

jephthah 1,888 Posting Maven

Kudos to using code tags correctly for your first post! :)

but i dont understand the goal, here.... i see that you read player's names ... but where's the "random matchup" of teams come into play, and what's that got to do with the players?

jephthah 1,888 Posting Maven

LOL WUT? is this a love letter to Narue?

well... damn. I just don't know what else to say.


.

Aia commented: In the cows' word, bullshit is not a swearing word, but a mickey mouse thing is known regardless of who you are. +15
John A commented: LOLWTF +20
jephthah 1,888 Posting Maven

sorry, im just annoyed because i cant ever compile your code, and its taking forever for you to believe me.

jephthah 1,888 Posting Maven

it still doesnt compile with my standard GCC compiler.

you're not allowed to intially declare variables inside your for loops, for one thing. that only works in C++.

for another thing, int val = int(a[i])-48; is illegal in C, as well.

and why are you STILL using gets()?? we've been over this already. now take that out and replace it with something sensible.

.

jephthah 1,888 Posting Maven

I am well aware of Netscape going open source which ended the company.

Then you're not well aware of anything regarding this issue.

Netscape Navigator was a proprietary browser that was licensed to personal users for free. Internet Explorer soon dominated the market due to a number of factors, including monopolistic practices by MSFT and bad business decisions by Netscape. After the release of IE 4.0, Netscape was all but dead in the water.

Netscape, as a business were totally outclassed and outgunned by Microsoft. They open sourced their browser's code under the Netscape Public License (NPL), then shortly thereafter sold the licensing rights to AOL.

Netscape was never, at any time, GNU.

GNU is but one type of public license for free and open source software. since obviously you're not talking about GNU, you should start using the term FOSS (Free and Open Source Software), or just "open source" instead of GNU.

I have an idea that I want to be GNU but I don't want it stolen.

you dont make any sense. if you don't want it "stolen" then don't release it to a public license.

take your gold plated code, lock it up in a vault, sell your distributed binaries for ridiculous profit, then retire in the bahamas.

.

jephthah 1,888 Posting Maven

i actually worked at a place that used a Caesar Cipher to encrypt user passwords for the operators who ran the production equipment.

and the "encrypted" password file was stored locally on every production computer.

no joke.

my first day there, i was like.... "LOL, WUT?" :-O

jephthah 1,888 Posting Maven

GCC is the standard. yours is the derivative. anyhow the problem is (probably) not the compiler, the problem is that you're using non-portable, implementation-specific libraries to solve a trivial problem combined with poor coding practices.

if you're going to present a pedantic solution to be used by various people around the globe on a variety of platforms and compilers, then YOU'RE the one who needs to conform to the basic standards, and not try to sell us on your flavor-of-the-month.

The algorithm is right, the syntax is right,

actually its not. on the standard GCC compiler, in common and widespread used around the world, even if you get it to compile, the program operation FAILS to work correctly.

Fails. plain and simple. now you can either accept this fact and recheck your assumptions, or you can stand around like a dunce and continue argue your support for a failed implementation.

.

jephthah 1,888 Posting Maven

whatever, dude. you made the assertion, not me.

proof (prf)
n.
1. The evidence or argument that compels the mind to accept an assertion as true.

so, next time, when you want to say :

"check it out people see if it's correct and if not tell me where it's wrong"

how about saying:

"check it out people see if it's correct and if not tell me where it's wrong"

instead of

"here is the proof"

you see, words have meaning. they're funny like that.

jephthah 1,888 Posting Maven

nobody wants your email address. and if you were wise, you wouldnt want your email address to be posted on a public forum.

i mean, unless you like getting 20 ads for Viagra and emails from the King of Nigeria every day.