jephthah 1,888 Posting Maven

yeah, theres obviously a number of different ways to approach such a "tutor"

i think SANZ is going to have to give us a bit more info.

it does sound like a fun little project.

jephthah 1,888 Posting Maven

nice

jephthah 1,888 Posting Maven

yeh there's a better way.

it's called "winsock"

learn it.

jephthah 1,888 Posting Maven

1. what's wrong with winsock, that you need some secret socket library? and i doubt VERY SERIOUSLY that it's "improved" in any way. At best, it will be equivalent. more likely it will be a level of abstraction from winsock that just adds overhead, and probably unintended bugs.

2. system("cls") --- that's just horrid practice.

3. gets ... who taught you to do that? don't listen to that person any more.


2 and 3 are evidence of sloppy, poor programming, but #1 is a big deal. you're not going to get very far with having people help you debug as long as you're doing sketchy stuff like that. lf you're going to be "FTP protocol" then you better learn how to use winsock for yourself and not rely on some suspicious secret library. i don't care if your friend is a genius.


.

jephthah 1,888 Posting Maven

yes....

oops. i mean, no.

jephthah 1,888 Posting Maven

you have "no clue" ??

okay, well first thing: how is this typing tutor supposed to work? what's your plan?

I'd think theres a few overall requirements....

(1) print some text to the screen that the person should type.
(2) start a timer, and begin collecting typed input.
(3) once they indicate they have stopped typing, stop the timer
(4) calculate total (elapsed) time, and the number of errors in their typed text.
(5) print results, allow them to try again or exit

then maybe draw a diagram of some functions, describe what task each function should do, use pseudo code to describe the functions inputs/outputs/return values, and indicated dependency direction of the functions.

and finally, start here:

int main()
{
    // insert code here
}

Once you've got it filled out enough so that you can ask a reasonably specific and coherent question... come back here and post your code.

In the meantime, please ask your instructor why (s)he insists on using such a piece of crap compiler (Turbo C), as it is 15+ years out of date, employs non-standard C libraries, and virtually NO ONE in the industries of the modern world ever uses it???

write down their answer, then post it here please.

thanks.

.

jephthah 1,888 Posting Maven

how about the part where he wanders in and says:

"Hey, y'all do my homework for me, mmkay?"

isnt there a link on that one?

jephthah 1,888 Posting Maven

AT commands are serial

so you will have to first deal with USB-Serial conversion.

but yeah, throw that Turbo C trash away real quick before it makes you a completely worthless programmer.

(an aside to Salem, or anyone else: where are all these Turbo-C people coming from? how does Borland keep perpetuating their shi**y compiler?? )

jephthah 1,888 Posting Maven

good thing Duoas is some kind of mindreader.
:P

as for myself, I still dont know what the question was

jephthah 1,888 Posting Maven

the <dirent.h> library has the following functions

int            closedir(DIR *);
DIR           *opendir(const char *);
struct dirent *readdir(DIR *);
int            readdir_r(DIR *, struct dirent *, struct dirent **);
void           rewinddir(DIR *);
void           seekdir(DIR *, long int);
long int       telldir(DIR *);

http://www.opengroup.org/onlinepubs/007908799/xsh/dirent.h.html


if you're confined to Windows-specific solutions, theres an implementation of this for Windows
http://www.gimp.org/~tml/gimp/win32/dirent.zip

if that's not acceptable for homework purposes, then maybe you can just get away with a system call like strcpy(myBigString, system("dir")); .

jephthah 1,888 Posting Maven

VERNON: I think that giving beginners malloc is like giving a child a gun and saying "dont shoot anyone, mmkay?" ... ive become quite weary of fixing buggy programs written by someone who thinks they know how to use malloc() when the really don't.

ALBAN: what Vernon is getting at, is that you CAN NOT simply declare an array with a variably number of elements. the array size must be declared with a constant, hard-coded value.

whats the maximum that "sa kufiza" could possibly be? make your array at least that size, then. youre not going to run out of RAM.

once you get "sa kufiza", then only use that many elements of the array.


.

jephthah 1,888 Posting Maven

plz solve my problem.
thnk u. bye

haha no thnk u bye

jephthah 1,888 Posting Maven

you need to ask a question, if you want an answer.

jephthah 1,888 Posting Maven

i agree. i thought about including that in my original answer, but decided to stick to the question as presented. some of the posters here (not necessarily this one) sort of implode if you throw too much at them.

anyhow... yeah, change your answer variable to type "double" , use the absolute value of the power to calculate the answer, and then throw this in at the end: if (pow<0) ans = 1.0/ans; pretty simple, really.

.

jephthah 1,888 Posting Maven

because he doesnt have to handle negative powers for his CS 101 class.

silly.

jephthah 1,888 Posting Maven

okay...

someone's gotta give me a cookie for that bit of cleverness.

mitrmkar commented: one cookie comes here ... +2
jephthah 1,888 Posting Maven

aha. i knew someone was going to call me on that.

:P

jephthah 1,888 Posting Maven

glad to hear it

jephthah 1,888 Posting Maven

well, you can use format specifiers

"%.3f" for instance will print up to 3 decimal places but only if they are non-zero digits.

"%.03f" will always print 3 decimal places even if they are zero digits.

jephthah 1,888 Posting Maven

its an expression.

as in, don't waste your time "inventing" something that's already been done.

GMP may not be "Standard C++" but it is one of the industry standards.

jephthah 1,888 Posting Maven

you noob. you're banned.

just kidding.

but seriously, you cant have a single array of floats "mixed with" ints.

they're all either one or the other. probably floats. some of the floats just happen to not have any fractional part.

i'm not sure i fully understand your question... you want to print them out exactly as entered? i guess theres a number of ways you could do this.

one way would be to input them as strings, and store them in a string array, then convert them to the appropriate value when needed. ... or, along those lines, a structure where you have the "as enetered" string element, along with a floating point "value" element

is this making sense? is this relevant to your question?


.

jephthah 1,888 Posting Maven

yeah, i guess mine was redundant. i still dont think well in recursion.

jephthah 1,888 Posting Maven

if you haven't yet, you should really read the Beej Guide

http://www.beej.us/guide/bgnet/output/html/multipage/structs.html

jephthah 1,888 Posting Maven

here's your problem:

if(y<=1)
return 1;

it should be:

if(y==1)	
		return x;
	if(y<=0)	
		return 1;

.

jephthah 1,888 Posting Maven

okay its early still, and im feeling pleasant:

PHOENIX,

you need to back up, and get some basics. I dont know how you got this far being so helpless.

look, do this simple exercise:

write a short program to "roll three dice" and print the results to the screen, without graphics or using any of that stuff your instructor gave you.

just start like this

#include <stdio.h>

int main ()
{

   // insert your code here

}

and make it print to a simple terminal something like this example:

Press Enter To Roll Dice...

Dice Rolled Are:  [6] [3] [5]

Press Enter To Roll Dice...

once you get that working, apply what you've learned to filling out the stubs in the rest of the assignment program.

and at the very minimum, you need to be able to do this by yourself. if you cant even handle this simple assignment, I suggest you seriously consider dropping your class.

jephthah 1,888 Posting Maven

AHA

Because the Glorious State of Arizona ... does not use Daylight Savings Time.

It's like the only state in the US that doesnt. Why, I don't know. My guess is it's Phoenix's fault. A truly miserable city, the culture is terrible, and the people were tiresome.

so your Rogue Wave libraries are working correctly.

EDIT: some parts of Arizona do use DST. Some of the Native American reservations in the NE part of the state, are not under state jurisdiction, and choose to follow DST like the rest of the country. I wonder how your RW libraries handle that

.

jephthah 1,888 Posting Maven

you want to know how? it's all quite well documented.

go here, here, and here

or, if you must, here

have fun


.

jephthah 1,888 Posting Maven

yes, there are ways to use network.

it's called socket descriptors.. But trust me, if you just only "kinda get" how to read a .DAT file from a local drive... well, you don't want to go there just yet.


.

jephthah 1,888 Posting Maven
jephthah 1,888 Posting Maven

and we're supposed to be able to debug your proprietary, enterprise-class library functions .... how?

what's wrong with <time.h> that you need some non-portable obscure library to calculate UTC?


.

jephthah 1,888 Posting Maven

never mind. what he said ^


.

jephthah 1,888 Posting Maven

thnx 4 yo info...

fo' shizzle


.

jephthah 1,888 Posting Maven

quintillion? thats not a large number.

now about seven years ago, i worked on a cryptographic accelerator with a 4,096-bit number... that was large


,

jephthah 1,888 Posting Maven

in an oversimplified nutshell:

C++ is a higher level, "object-oriented" language more suited for user-interface intensive applications. C is a lower level "procedural" language more suited for hardware interfacing applications. C is also the foundation of many higher-level languages, including C++.


But it should be pointed out that williamhemswort's link is one of those articles about "why <my favorite language> is better than all the others"

some wild-eyed zealotry? probably not; C++ is a solid general purpose language. I'd say it's just a bit of biased overenthusiasm. But whatever, programming languages are tools. nothing more, nothing less....

like any tool, use the best one for the job. Just because you can pound some nails in with your world-class wrench, doesnt mean you should

.

jephthah 1,888 Posting Maven
jephthah 1,888 Posting Maven

Our doctor want us learn how to make these shapes by using loops for exam question.

sweet.

my doctor just wants me to bend over and take a deep breath. :(

i should look into changing plans.


.

jephthah 1,888 Posting Maven

i dont have an answer to your question.

but, if you don't mind me changing your question somewhat, the new answer becomes:

Code::Blocks

seriously. best thing i've found in a long time ... (with props to Salem)

(ps: get the "MinGW" version. that way you can use either your MSVC compiler, or the GCC compiler, and switch back and forth as you wish)


.

jephthah 1,888 Posting Maven

you can call Perl scripts from C/C++, but it's not particularly useful if you plan on distributing your code to any other machines.

because you'll either need the full Perl installation (plus any obscure modules you might use) installed on (or networked to) every target machine, or you'll need a Perl Development Kit ($$) to build super-freaking-huge EXE files. either option is kind of gross.

If you really want Perl's powerful regex functionality, use the Regex++ engine for C++. It pretty awesome.

http://www.ddj.com/184404797


.

hammerhead commented: Thanks I did not know about regex++ +3
jephthah 1,888 Posting Maven

around here, i learn something new every day. and typically from the same 3 or 4 people :)

.

jephthah 1,888 Posting Maven

PLAYST205: this is a Really. Common. Problem. one day you may have the unfortunate luck to revisit your posts here, and you'll be (rightfully) embarrassed at just how whiny and helpless you're acting over something so trivial and mundane.

ANYHOW... most text editors have a hotkey that will locate the mate for any given brace/bracket/parenthesis. for this very problem. For instance, in TextPad, I click on any brace, hit CTRL-M, and it takes me to its corresponding mate. MSVC++ and Code::Blocks have something similar.

go through your braces looking for the mates like that, and soon enough you will find that it cant locate the matching brace, or it thinks a match is something that obviously isnt. therein will be your missing/extra brace


.

jephthah 1,888 Posting Maven

sounds like the bestest way to handle this is not to use a DIFF style comparison function, but merely to parse each file looking for the parameter in question.

find the parameter, extract its corresponding value, compare the value(s) to each other and/or some initial/reference value

this is the sort of thing that Perl is made for.

jephthah 1,888 Posting Maven

this is actually quite an involved project. As interesting as this is, i must apologize, I just don't have time to commit to this right now. it's really going to be a lot of work

here is something that may help you: C program ("streamer") written for linux that allow commandline interface for controlling webcams.

http://www.linux.com/base/ldp/howto/Webcam-HOWTO/framegrabbers.html

but being a linux app, it presumes you have the drivers installed.

http://qce-ga.sourceforge.net/

there are similar windows apps, but they involve drivers and the Windows API.

i hope you didnt put this project off to the last minute.

.

jephthah 1,888 Posting Maven

or you could pass in the name of the file on the command line

int main (int argc, char **argv)
{
    char filename[MAX_FILENAME_LEN];
    
    if (argc>1)
        strcpy(filename,argv[1]);
    else
        strcpy(filename,"default.dat");

    if (fopen(filename,"r+b") == NULL)
    {    
        printf("file <%s> does not exist!\n",filename);
        exit(0);
    }
    
    ...

}
jephthah 1,888 Posting Maven

"my brother"

needs a tic tac toe program written

"in a couple hours"

LOL, you people .... i swear, where do you come from?

well "your brother" is pretty much screwed, isn't he?

like Salem said... we're all happy to know that that there will be one less worthless, cheating, incompetent wannabe coming out of CPE college, when you -- i mean *cough* "your brother" -- gets found out for being a slackass plagiarizer.

jephthah 1,888 Posting Maven

ah... dangit, my sarcasm generator is down this morning. *sigh* ... This is my own fault. I should have followed AIA's lead and left it alone.

Okay... as a final parting gift, here's what you need to do:

take each of the provided stubs (function headers) and fill each of them in with code to make each of them do the task that is specified.

then in the main() routine, tie them all together.

and in the meantime, if you can ever formulate a SPECIFIC, COHERENT question, come back, and maybe I'll care again.

jephthah 1,888 Posting Maven

umm... well, how did you get this program as far as you did?

where in the program, exactly, are you having problems?

and don't tell me "everywhere".

jephthah 1,888 Posting Maven

"URGENT" is so played out. But, hey, you're getting better... Your only other post here, from 5 months ago, was "HeLP I need it today"

next time, try titling your post "HALP HALP MY ASS IS ON FIRE!!!!!1" and lets see what happens.


.

Salem commented: I am dyslexia of borg - your ass will be laminated. +17
jephthah 1,888 Posting Maven

SOMENAME:

you're essentially on the right track, and you've basically got it. i think you're getting bogged down in some detail or other.

check this out, and see how it's pretty much what you're doing:

#include <stdio.h>
#include <string.h>

#define MAX_LEN_SINGLE_LINE     120   // ?

int main()
{
    const char fileOrig[32] = "myOriginalFile.txt";
    const char fileRepl[32] = "myReplacedFile.txt";
    const char text2find[80] = "lookforme";
    const char text2repl[80] = "REPLACE_WITH_THIS";

    char buffer[MAX_LEN_SINGLE_LINE+2];
    char *buff_ptr, *find_ptr;
    FILE *fp1, *fp2;
    size_t find_len = strlen(text2find);

    fp1 = fopen(fileOrig,"r");
    fp2 = fopen(fileRepl,"w");

    while(fgets(buffer,MAX_LEN_SINGLE_LINE+2,fp1))
    {
        buff_ptr = buffer;
        while ((find_ptr = strstr(buff_ptr,text2find)))
        {
            while(buff_ptr < find_ptr)
                fputc((int)*buff_ptr++,fp2);

            fputs(text2repl,fp2);

            buff_ptr += find_len;
        }
        fputs(buff_ptr,fp2);
    }

    fclose(fp2);
    fclose(fp1);

    return 0;
}

it has a couple caveats... it requires that you #define the max length of a file line. any that exceed that length are at risk of missing an instance of the search text. could be a candidate for a carefully implemented malloc() call

also, it won't find a search text that is split across two lines. which would be a serious flaw in many situations.


.

jephthah 1,888 Posting Maven

okay, apparently most webcams do not have a command line interface, and this will not be as easy as i assumed.

im still lookin

jephthah 1,888 Posting Maven

but yeah, what AIA said... what exactly is your problem now?