~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If everybody thinks that today is November 11., then why not January 1.? (11. 11. or 1. 1.... minor difference)

Thanks for letting me know that Miss Dani's bday is on Nov 11, was waiting for somone to clear the mist on when exactly the bday was D:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That is not true. You can make char* point to int* and vice versa.

I said you can't make a int* point to char data and not char pointer.
Of couse when dealing with commands like memcpy which deal in raw bits, you can use any type of pointer, it doesnt bother -- all it does is copy the bit representation from the source location to the destinatino location.

What I meant was you cant do something like:

int* ptr_int = 0 ;
char* ptr_char = 0 ;
char ch = '\0' ;
int i = 0 ;

ptr_int = & i ;  // ok
ptr_char = &ch; // ok
ptr_int = &ch ; //error
ptr_char = &i ; // error

Of couse you can make it go away with typecasting but thats a different story altogether.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Rational Rose and Enterprise Architect -- but these are paid ones. Of course if you want to learn then these work fine.

For free modelling tools which generate source code from UML and vice versa look here

BTW these tools are not called reverse engineering tools they are called Modellign Tools -- reverse engg implies in the sense of coding to hack open the .exe file and work with the Assembly language to make the required changes (normally used for making cracks for illegal softwares).

Reverse engineering is taking apart an object to see how it works in order to duplicate or enhance the object.

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe this should help:
LINK
ANOTHER ONE

Just let me know if it is any good.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Gosh this is one long birthday. This is the only thread I know that is active 365 days of the year . Do you fellas know when her actual birthday is? Cos I just checked the forum index and it aint today...

Naa seriously I dont know when Miss Dani's birthday is , but when everyone was wishing even I pounced on the chance.

...I even got to place my sacrasm and that too for free. :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ternary operators anyone?

b = (*fp == *(fp + 1)) ? true : false ;

Use the same thing for d and it should be fine.

variable_name = (condition) ? (if_condition_true_return_this_value) : (else_return_this_value)
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hehe dont worry, you will very soon get enough money to earn a custom title via sponsorship.

PS: Thanks to your rep my rep title changed to "glorious beacon of light".

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Here I have 1.3 K posts and all they do with me is give me this:

Banned ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nevermind, SOS was right, the problem was because it was 1 going in, sorry :(

Would you please elaborate so that the other people readign this thread would be enlightened and gain some knowledge?

Hoping for your explanation, so that other beginners get the help they want.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IF you give input like:
1 2 3 4 5

Your subtraction statement

sum = sum - alms[i] ;

will generate
-1
-1 - 2 = -3
-3 - 3 = -6

So the ans will be -ve if you supply only +ve numbers. Is that the ccase ? Or is the answer -ve even when the numbers are -ve.

Like
1 -3 4 -5 etc.

Please post a sample run of your program with input data as well as the answer.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In your first do while loop the condition you have used is while( trks < nums ) WHen the program control enters the loop the value of trks is already 1 and the condition you are using is while( trks < nums ) .
So if the user enters that he wants to sum up 4 integers, you end up just askign 3 input from the user due to your faulty loop condition.

Just to let you konw, do while loops are confusing..better go with a for loop which makes the appearance of bugs in the program less.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thread involving regards and congratulations to miss Dani usually end up being locked...hope this one doesnt suffer the same fate.

HBMD (happy b day miss dani)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

At the risk of sounding as if I have got a big head, I'm sure I'm right. I suppose have been writing C programs since about 1987, and usually they are between 20 and 30 thousand lines long. But I hate to make a fool of myself, so I have double and triple checked what I wrote above.

My reasoning is as above. In the syntax of C |= OR's the right hand operand into the left hand operand.

Hehe looks like you misunderstood. Mr. Salem said the above statement to the OP and not to you. So just chill since the sarcasm wasnt intended for you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Post a sample of the data you are using and any reason why the data is in so complicated a format ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For multiplication:

a[i] = ( a[i] - '0' ) * 2 + '0' ;

But this would work only for digits from 1 to 4.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You cant as such check for such conditions in case of a simple sort like bubble sort.

Take for eg. this array.
1 2 3 4 5 6 8 7

During the first seven passes no swap is performed since the next number is always greater than the current but a final swap is done in the last pass to sort the array. You cant as such terminate a bubble sort based on the flag that swap is performed or not.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you really want to learn something for free you can see the set of tutorials provided in this thread which gives everything from while loops to for loops to all the basic C constructs.

I dont think anyone would post any code since its against the forum rules for moderators to post code but you can see some examples by searching Daniweb code snippets for [search]Pascal Triangle[/search]

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Well exactly. I didn't put a in my code, I just put a.

Even I know that, I was just clarifying Mr. Andors point.

I don't think I can use isdigit because I'm not supposed to decremenet 0.

What does this mean ?

How is '0' - 1 = 9 ?!

If you encounter 0 in your string, how would you handle it.. surely you cant put -1 ?

And what if my task was to, say, multiply every digit found by two? How would I do that?

But suppose your digit is greater than 4.. then how do you propose to do it since it would then imply making spaces for new digits ?

State your program requirements in more detail.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Be more specific, state your context and post your latest code attempt. Being vague wont help you at all.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

hi i need to write a while loop to print out groups of stars shown in the attachment the middle set?? cud someone provide me with an answer please as i am desperate to get it working. thanks in advance

Hmm looks like you didnt like my answer here, you could have atleast told me, I would have tried to explain you in a better way, or is it that you are expecting easy answers ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

First of all dont use scanf() to obtain the string from user, use [search]fgets( )[/search] which is much safer option. Something like:

char buffer[BUFSIZ] = { '\0' } ;
printf( "Enter the string: " ) ;
fgets( buffer, BUFSIZ, stdin ) ;

Also there is an inbuilt function in the header file ctype.h known as [search]isdigit( ) [/search] which returns a non zero value if the given character is a digit character.

In your while loop check for digit character, increment the counter, and scale the result in the range 0 - 9 after subtracting the value with 1.

eg.
'0' - 1 = 9

And I don't quite understand how you can use 'a-=1' when a is a string

a is a character array but a is a character and you can add or subtract from a charcter since they are basically represented as integers ASCII values.

If any doubts repost.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Rock and Electronic for me.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Naa here I didnt write the code buddy, just replaced the one function call with another thats it.

Also the MOD rules state that I am not allowed to post entire code to someone so I wouldnt dare go against them.

Oh.. wait.. damn..my crown jewels are dropping down..hehe

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not wrong though, since I corrected my mistake before anyone else did. Plus I don't have a compiler to test anything.

Agreed...

If you've got a free basement I've got some chicken wire.

Its a good thing that I am non English plus I dont get to understand 99% of your humour, so all is well. :twisted:

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In hindsight I think that might be ok.

Hehehe look before you leap. ;)

Here is the workiing code. I just replaced fscanf( ) with fgets( ) and it was fine.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define numofstr 50
#define strleng 101

int compare(const void *,const void *);

int main()
{
    FILE *a,*b;
    char s[100] = { '\0' } ;                            /*starr - string array*/
    int i=0;
    char starr[numofstr][strleng] = { '\0' } ;

    a=fopen("non_sorted.txt","r");

    while( 1 )
    {
        if (! fgets( s, 100, a ) )
            break ;

        if( s[strlen( s ) - 1] == '\n' )
            s[strlen( s ) - 1] = '\0' ;

        strcpy(starr[i], s) ;
        i++;
    }

    qsort(starr,numofstr,strleng,compare);

    b=fopen("sorted.txt","w");

    for(i=0;i<numofstr;i++)
        fprintf(b,"%s\n",starr[i]);

    return 0 ;
}

int compare( const void* a, const void* b )
{
   char* arg1 = (char*) a;
   char* arg2 = (char*) b;
   return strcmp( arg1, arg2 ) ;
 }
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nope. Still doesn't work.

Ok paste your entire code along with your unsorted data.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm helping by offering him good advice. You on the other hand have given him a piece of code that don't work. And you're leading him down the garden path.

If you don't like the truth then I'm sorrie.

Yeah I like truth but not twisted truth.

I gave him google links of how qsort is applied. I didnt write that tutorial so any problems he is facing I am trying to help him out unlike you who only says this is wrong and that is wrong without giving a shred of help.

Actions speak louder than words. All you do is just say this is wrong and that is wrong but never attempt to help someone out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

fscanf( ) accpets the addr of the variable where the data is to be stored.

What you have is:

while(fscanf(a,"%s",&s)!=EOF)

Try replacing &s by &s[0] or s and then see.

No offence but I'd scrap that and try again. SOS has given you a crappy example ha ha.

If you cant help atleast keep your bad sense of humour to yourself.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm looks like the code sample is broken.

Try this:

int compare_ints( const void* a, const void* b ) {
   char* arg1 = (char*) a;
   char* arg2 = (char*) b;
   return strcmp( arg1, arg2 ) ;
 }
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Study the links which I have given you, my writing the code wont help you in any way.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dont use direct assignment operator. You can't treat strings like normal data types in terms of assignment.

You need to use strcpy to do somthing like that.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For a solved eg. see here.

For documentation look here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

P.S. I'm asking because I want to arange my list of music albums, because right now, the names are held in a completely sporadic manner in a Word document.:cheesy:

Copy and paste the contents of the word file in a clean text file to avoid unnecessary hassles. I dont think there would be a requirement of your course to read specificallly from a *word file* .

Word File is not a text editor but used to present text and such tools are not used for storing data. Data files of user either have a header format which the user has designated (like a game's save file) and he knows or they are just pure text with custom extension (names.sdc) .

This might sound stupid...but what is a container? Either it's an English word for something I'm familiar with (English isn't my first language) or I simply don't know what it is.
And please name some containers.

Simply put a container is something which is used to store loads of data or records and which can be accssed in O (1) time if the index of that element is know.

THe basic containers are well -- arrays :D in C and Vectors in C++.
If you using arrays you can use the inbuilt qsort( ) method to sort the array and if you usign vectors you can use the inbuilt sort( ) algorithm.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe you should read this regarding your size query. It is an excellent example and maybe will suit your needs.

Also regardign your pointer query read this.

Hope it sufficed bye.

The three have a size of 4Bytes, no matter what type it is. But, how to find out the restrictions?

Pointer of type void can point to any type of data if thats what you asking while int type pointers point only to int data and char type pointers point to char type data.

Previous versions of malloc returned char* so we had to typecast them to suit the needs of the program but it has changed in C99 where malloc returns void pointer (void* )

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I like the fomat of tutorials of this site, maybe this should help as a guideline for you.

Also just wanted to let you know that your site takes a bit too long to load. Maybe its jsut my computer or something but just wanted to let you know ....

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I have read this somewhere in the context of Processor architecture. The compiler tries to align the data and the pointers along the boundaries i.e. in multiples of 4.

So the addresses are given along the lines of multiples of 4.

Not very sure about it but atleast this should give you a starting point.

JoBe commented: Great help, nice person. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

or Codeblocks

Even this one is good.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

BUt still you havent answered Wolfies question -- what are you giong to develop usign that ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I dont think so, its too old.

VS 5 -- VS 6 -- .NET 2003 -- .NET 2005

It must be having a lot of problems. But why not use the free IDE's out there ? Why are you so intent on using MS products ? Does your project involve too much MFC and all that ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Just sayign doesnt work wont do.

Are you getting compile time errors, run time errors, program not functinoning as you expected ???

Explain your problem in detail and the things you are experiencing.

[edit]
Ah Mr. Salem has already brought down his MOD stick on the guy ;)
[/edit]

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OK next question. I am trying to change the array tokenPtr is pointing to.

Since you have made the functino parameter as char const * const tokenPtr you can neither modify the poniter nor the data pointed by it if thats what you asking.

Also my while loop is only doing the first word in the sentence.

See my comment marked in red below.

Oh yeah... every time I run this I get an error asking me to send a report to Microsoft. I think this means some loop in here is not working properly and I am assuming it is this while loop. I am not that familiar with tokens so it is hard for me to understand where the problem is.

This message generally means segmentation fault which occurs when you try to access or change a memory location that doestn belong to you. Simply put its something bad related to pointers.

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

#include <cstring>
using std::strtok;
using std::strlen;


const int SIZE = 80;

// function prototype
void printLatinWord( char const * const  );

int main()
{
char sentence[ SIZE ];
char *tokenPtr;

cout << "Enter a sentence:\n";
 cin >> sentence; 
// you need to use fgets( ) to get the entire sentence with
// whitespaces. cin stops at the first whitespace.

// if using C++ use cin.getline( )
 
tokenPtr = strtok( sentence, " " );

while ( *tokenPtr != NULL )
{
    printLatinWord( tokenPtr );
    tokenPtr = …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

iand, for my information does *(ptr+1) do the job. coz the aray is of type int which most probably takes two bytes. so isnt it supposed to be *(ptr+2) or just *(ptr++)

No, the pointer arithemetic takes care of the inrement for you once you mention the pointer type. Hence if you have a pointer to an array of integers then doing ptr++ would do the trick -- ie increment it automaticallly by 4 bytes or whatever be the size of the datatype.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Have you tried reading some google pages..

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thats because I think you usign *nix while the system("pause") is windows only (methinks).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Whoa quite a lot happened here while I was away....atleast this is one particular discussion where things started getting hot without my involvement :D

But why ban someone for a post in Geek's lounge which is just an outlet of our personal opinons ? Maybe I missed a lot of things here thats why dont know the whole senario.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But I fight like a lion.

Too many animals in here...:cheesy: Maybe we need some humans..

And btw you are under no obligation to buy whatever new OS MS puts in front of you. THey market their product to the world not to a single individual. THere are many ppl out there who are filthy rich and dont mind spending big bucks on the latest tech things as long as it makes them happpy. So problems with prev OS or shortcoming with them are not the only points you should be considering.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You guys should be using code=cplusplus instead of code=cpp.

So how does the keyword "cpp" gets parsed. It means that like cplusplus even cpp is a valid token ? I thought if I typed the code type wrongly it would simply igore the code tags. So is "cpp" not wrong ?

Ha ha, silly SOS and his typos. Dearie me.

Grrr......;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am sorry but I dont understand the logic in this. Care to explain a bit more?

I meant that the main source of income imho for MS is the sale of its OS. If they made OS free then they would have to rely on the sale of their softwares and many people nowadays have come to know of Open Source softwares whose quality is touching the paid ones.
Eg. GIMP <-> Photoshop
MS Powerpoint <-> Impress etc.

And usually something will go wrong. Remember these people who are afraid to "experiment" as you say are not geeks unlike us. They are non-techies but who contribute as much as we do to this world. They can be risk takers like enterpreneurs, who has other things to worry about than installing the next OS patch. So the easier they can get their work done, they go for it. For them time is the most important factor. Not hyperthreading or some other technical buzzword. They only want to browse internet, read and send emails. Maybe do some accounting. I know that the command line of Unix is ver yvery powerfull. But try reading email in Pine.

I dont expect such people to know everything and by lack of knowledge I meant that if someone who knew his way around in Linux helps these people and sets them right when the *experiment and something goes wrong* life would be much easier for them.

By default we dont know …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hehe Chaky has managed to throw himself to the *wolves* :D