WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I try read a story text file using c. the problem is i want one paragraf in one variabel. i am confuse how much i should alocate the buffer size?

Unless you know how many characters in your paragraph, you can't just allocate a buffer. As AD suggests, you can set up an array of pointers, assuming you know how many paragraphs you need. There's another function you can use named realloc() . You malloc() for the first line you read, then realloc() to add more space for each line additional line you read. When you get to the end of the paragraph, increment the paragraph count (like AD did) and start again with a new malloc() .

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Deal me in, boys, I just got paid!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

:)C'mon Walt -- surely you come from the time when rote memorization was taught?

Yep -- and if you don't use it, you lose it. I've never typed most of those words (they all came from a list).

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, don't know how to load the pic, and can't delete the message...

Oh well.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Definitely kool pix. But why flash?!?!?

I used a satellite map site to look at the Pyramids and Stonehenge -- really neat hobby -- but these pix are amazingly clear!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Don't know. Have you tested the hidemouse() function outside of this program?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I always think that a programmer should know what's under the hood. I think that starting with Assembly and then moving up is something that new programmers should always do. It means that you have a good grasp as to what is going on and can optimize your code by getting closer to the CPU.

I disagree with the timeframe, but not the concept. Start with a higher level language like C/C++. Once you get a good grasp of programming concepts, then take assembler to see what's under the hood. Trying to learn the terse programming of assembler while trying to understand the concepts of programming in general is just too much IMO.

It's an unpopular opinion but I'm glad I took the time years ago to go through x86 and 6800 assembler classes (these were geared for embedded devices) as it gave me a very good understanding of what is going on in the CPU and how the memory is being organized and utilized. It really gives you ultimate control over your system as well.

I myself know PDP-10 and PDP-11 assembler as well as 80xxx, and have a basic understanding of a couple more, so I know where you are coming from. I do agree that knowing assembler is a great idea. It just shouldn't be the first language.

John A commented: Very well put. - joeprogrammer +4
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

dancing. And dancing

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Me and my shadow...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I usually have problems with the rule "I before e, except after c, or when sounding like a such as neighbor and weigh..." thanks to:
albeit
atheist
codeine
counterfeit
deify
Einstein
either
foreign
forfeit
height
leisure
neither
protein
seismic
seize
sheik
sovereign
their
weird

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi, i have made a code. Its meant to announce a "Sentence" but i dont know how to make a string into a sentece. The string up to now only announces the first word of the sentece.

//Announce
}else if(memcmp((void*)lpcLine, "/announce ", 10) == 0){
 bRet = false;
 char AMsg[200];
 sscanf(lpcLine, "/announce %s", &AMsg);
 PostAnnounce(AMsg);

eg: /announce Hello Their

and all i see then is

Hello

instead of Hello Their

This would be best done using strcpy() and strcat() since you are using C-strings. Leave sscanf() for conversion from strings into numbers.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Only thing I'd add is extend the IF around the guts of the program:

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

int main (void)
{
    size_t len = 0 ;
    const char a[] = "c:/a/a.exe" ;
    const char b[] = "d:/b/b.exe" ;
    char buffer[BUFSIZ] = { '\0' } ;

    FILE* in = fopen( a, "rb" ) ;
    FILE* out = fopen( b, "wb" ) ;

    if( in == NULL || out == NULL )
    {
        perror( "An error occured while opening files!!!" ) ;
        in = out = 0 ;
    }
    else    // add this else clause
    {
        while( (len = fread( buffer, BUFSIZ, 1, in)) > 0 )
        {
            fwrite( buffer, BUFSIZ, 1, out ) ;
        }
    
        fclose(in) ;
        fclose(out) ;
    
        if(  remove(a) )
        {
            printf( "File successfully moved. Thank you for using this mini app" ) ;
        }
        else
        {
            printf( "An error occured while moving the file!!!" ) ;
        }
    }

    return 0 ;
}

This way if either file doesn't open there's no sense executing the moving... ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

the dish washer

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Mind you, she is 18 now and totally senile.

How can you tell? She's a cat! :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Damn my English [plonker]

That's not English. That's Britishish.... They like to make up words just to confuse the rest of the world. They think they own the language because they're named after it... :twisted:

The term found popularity in the UK after it's use in a long running TV sitcom called 'Only Fools and Horses' in which the main character constantly refers to his brother Rodney as 'you plonker.'

Especially on the telly! :cheesy:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@~s.o.s~
Thank you. Your correction is appreciated
@WaltP
Thank you also for your input.

You're welcome... ;)

I didn't know it was bad. I always use it to ensure that getchar() (to pause the program) is not going to read any thing left behind by any scanf() or any other function used. I read the linked reference, but I'm not clear why it is so bad except that it depends of the compiler to work properly.

Because it depends on the compiler to work properly. Let's assume you keep using fflush(stdin) because it seems to work for you. Then when you get a job you're using a compiler it doesn't work with. How long are you going to spend debugging your code wondering why someting that's always worked is no longer working? You'll most likely not even check that line because "it's always worked before".

What choice do I have if I still use scanf() until I learn something different?. Is fflush(stdout) as bad?

Use a combination of fgets() and sscanf() . Or use the code listed in that link to clear the buffer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i'm living in a tropical country so there really is no snow in our place...

What's your address? I'll mail you some....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Star Wars, fake too? I'm not honestly sure how to answer that :sad:. I suppose you are correct. ;)

Maybe they were historical documents intercepted from a galaxy far far away.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh, oh!! Me! Me!! **he shouts waving his hands wildly** :mrgreen:


(just kidding)

John A commented: Here you go :) -joeprogrammer +4
~s.o.s~ commented: Here you go my boy...;) - ~s.o.s~ +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Greetings all. Its been some years since I did anything in QB.

I need to manipulate a txt file so it can be imported into MSAccess.

Problem:
The file is already comma delimitted, however each line of text contains multiple records.

I need to insert a <return> after every 35 commas (fields), before I can import the data into MSAccess.

The txt file is rather large (>20 megs) and manually inserting a <return> when needed is not an option.

Any assistance is appreciated!
Moe

Read a character at a time. Write that character to a new file. Count every comma and at 35 output a <return> instead of the comma.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

...was just looking for a function that was already written and handled all of them rather than doing them each individually....

Nope, sorry. You have to be efficient on your own... ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Much of what these fight choreographers think is "exciting" is anything but (save if you are a 12-year old boy, perhaps).

Yeah, that must be it...

I wonder the same about American televison wrestling: most people today know it's fake but they still love it. :confused:

Yeah, so? Star Wars is fake too, isn't it?
Wrestling is entertainment. Just like Fight Club is. But to be honest, the entertainment value is lost on me, too. ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thank you, Joe. I get really tired of hearing that glogal warming is caused by "over-industrialized nations and their spoiled citizens". It's a proven fact that it is a natural cycle and we have little or nothing to do with it.

And add to that the average yearly temperature has risen a whopping 1.1 degree F (0.6 C) over the last century. Gee, in 600 years the low temp where I live could be -20F! Gee, that's too warm for me!

And, no, even this information is not the last word on the subject, but it does attempt to explain many of the alleged realities we see.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well I'm not looking for a single function to do all this really. I mean alot of HDs are formated in NTFS or FAT32, so if I'm correct HDs have something called FAT which says where everything is located. So how is that data expressed. Is it a list of pointers followed by its file name? Can C even get to it?

HD's have a File Alocation Table (FAT) or New Technology File System (NTFS) -- at least in Windows. They are two very different file systems. Linux uses FAT. Mac, who knows? A Google search will give you details of both.

Isn't C portable to the point you can creat an OS with it???

Yes. But you have to keep in mind each OS is written specifically for the hardware it runs on. So even though C is portable does not mean you can write an OS that's portable.

So I started doing c programing and now I want to understand how file systems like fat 32 and NTFS works. So I want to know how to create a file transfering program. So here's a few questions....

1 How do I do it the portable way?
-find file size

The only standard way is to read each character. Each OS and Compiler generally will have a way, but it's not portable.

-what data type to use in C to do the transfer

char

-explain the following:

2 How to do it through windows
-how …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
fflush(stdin);

is a very bad thing to do. See this for the reason why.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

As was implied earlier, who's qualified to Mod the new forum? Who knows RoR well enough to give help?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i want to read in and store the company names in a variable, but i cant for the life of me get it to work

Haven't you been here long enough to know that without knowing what you've tried (code) we can't help? We ain't psychic!!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... you win at poker night.

I put in a strawberry candle...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I take it no one has pointed out the last paragraph of the Rules yet.

I also seem to remember mentioning you have to give us information about what is wrong and enough information for us to understand the problem. You didn't do that again.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First you need to figure out what's wrong -- and that's the hard part. One thing that's probably wrong is way too many programs and services getting loaded when you boot like Real Audio, Quicktime, and other.

Look into Mike Lin's "Startup Control Panel" to remove unwanted startups. THat would be a good first step.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Here

Another VB-type language is Real Basic -- and it works on Linux as well as Windows.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Killer Klowns from

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Nielson rating do an extensive study of demographics and those boxes are placed in 1200-2000 homes based on their findings. These boxes give us the alleged number of people watching a program at any given time.

In addition they send out log books for people to keep track of their watching habits. This is added to the instant readings for a more accurate rating system.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I was in Detroit and got to see it fall real-time rather than at 11PM for once. (althought I don't make it a practice). I'm sure most of the country actually watches it. It's not just the "time" but the extravaganza of it. And I think the other time zones see it as the country's official entry into the new year.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

only to be

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"Life! Don't talk to me about life!"

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yep, pretty bad... and with a grosssssss ending!!!

The best IMO was in Star Trek's "Trouble with Tribbles" episode.

I still want to know why fight choreographers insist that a swing with fist or sword to the extreme top of the head is an exciting move. Even my grandmother can duck fast enough to avoid it!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

that compiler does not compile c++ code -- its a C compiler.:rolleyes:

Really? My copy of Turbo 1 does. When did they remove C++? :rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Whatever!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So I'm trying to decide if going to college for computer science or computer enegineering would be worth it. Or should I get a BS/BA in something I really enjoy doing (Like film or art) and just teach myself computer programming, opengl, direct 3d, etc.

Depends on what you want to do. Do you want to do film as a career? Or computers? Or both? Either case, yes, get a degree.

My passion has always been computers and film. I'm semi artistic and can learn to produce some great 3D art or effects for video games... but the same time I'm very logically minded and I understand how computers and programming works. I've taught myself evertyhing I need to know about web development, and I am moving on to OpenGL now (after having learned C++/C#).

Maybe get a degree in film animation and special effects. Get training in computer effects like all movies are now using.

I've heard that Computer Science is mainly theory, and that it's also very boring if you already understand how everything works. So is it worth it to do that, ...

Don't listen to people that don't know what they are talking about. It's far from only theory. If you're interested in CS it's not boring. If you don't care about it, booooooring!

...or should I just take something I enjoy (like film/art) and teach myself everything else I need to know to work in game programming/art?

That way I have a …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you accidentally hit the edit button then just click on Cancel instead of Save :mrgreen:

Probably hit save then realized he was in edit mode. See? The EDIT button position even bites Ancient Dragon! Need I say more? ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Not to be nitpicky, but cin is the C++ version of C's stdin. The overloaded >> operator is the C++ version of scanf.

So don't be nitpicky :p

Yes, you guys are right. So I change my statement:

Keep in mind, cin << is the C++ version of C's scanf() and must be used appropriately. IMAO that means -- don't! ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To be honest i don't know to much of the language yet, i jst started learning, it's c++ language, i'm finding it slightly difficult, i have books to help, but i wanted a bit more practical advice, the books help with input of the values, but not so much how to make the programme calculate, i.e. the pass/fail, moderating etc... that seems quite a task to me.

You need to take Bench's advice:

One way to begin with a task like this is break everything down is to bite-sized pieces.

In other words, can you input values correctly? Just do that step. Then move to the next step.

Ask specific questions and post the code that is giving you problems and we can help you correct it.

You probably want to break the solution down into several functions, to make life easier, and avoid repeating code

Just have main() call functions and each function does one step.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Keep in mind, cin is the C++ version of C's scanf() and must be used appropriately. IMAO that means -- don't! ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi All :mrgreen: ,
was mucking about with a small programme I have which makes a triangle pattern when entering in a number. It uses nested For loops.

I now want to create the same thing using functions as im only just beginning to learn the C language. I have started it but get One error. Maybe some nice person could suggest a few things ? :)

Only one? There are somewhere around 500 errors possible. Compiler errors. Runtime errors. Logic errors. Can you be a little less vague? What's the error? Where does it occur?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Unfortunately, many forum newbies still tend to do this; they'll dig up some old thread that was posted 2 years ago or something, and then piggyback the thread with a somewhat-unrelated support question, and creating extra work for some moderator.

Sounds like a job for SuperDeleteButton Man :mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is anyone there to provide me with some guidelines please

Suggestions will be appreciated..

Thank you

To what? You got a suggestion. You were also asked questions which you ignored. Please be less vague and acknowledge what has already been given.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To be honest, when perception and logic don't coincide, I know better than to trust perception. Being a magician, I rely on being able to make people's perception fly against logic.

An easy case in point -- look at any optical illusions. If you don't doubt your perceptions, then the picture is illogical, in error, physically impossible. Therefore reality is wrong. You must doubt your perception, or go crazy....

;)

Either that, or I don't perceive the logic of ~S.O.S~'s statement.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another one of those "I just got a tricycle for Christmas! How do I drive the Concorde SST?" questions. Please learn to crawl before you enter the Boston Marathon...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Not without telling us what is it's doing wrong. Yuo have to tell us what the ptogram is doing, and what it should be doing instead. And don't forget to read the announcement above about BBCodes so you can post the code readably.