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

The loop appears to be about right except you need to save the value of pos so that you can use it after the loop finished. The current code destroys the value of pos.

Hmm... I think it is more of a compilation error.

It would probably consider int n ; and int pos; as the redeclaration and flag errors.

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

My List:

Iron Maiden
Theory of a Deadman
Incubus
Papa Roach

and lots more but the favourite is :::: IRON MAIDEN !!!

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

Hmm... what happens if the capacity of array overflows ?
You state in your problem statement that the function returns -1 if the inserted element causes the array to have more than max elements , but still in your eg. you return 1 ?

Post two or three egs. specifying different cases so that the problem statement is a bit clearer .

BTW does your code even compile ?

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

Huh !!! What is the question ?
If you want to point out somethign in the code, highlight it so that i can know.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
string strd1 = "9";
int m=atoi(strd);

Got the error: error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'


how to change the second line to make it work?

atoi doesnt accpet a C++ style string but a C style string which si terminated with a null character.

Try something like:

string my_number = "1234" ;
int number = atoi( my_number.c_str( ) ) ;

It should get teh work done for you.

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

So, define pi** and tw** for me.

I defined what I used in my posts to mean what I had to convey. Why dont you define those yourself ?

An ass-kisser can be somone who goes around kissing donkeys.

Agreed

While your at it who invented the words "poo poo" and "pee pee?"

..definately not a sensible and sane person.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <string.h>


int main(void)
{        
    /* Initialization section*/

    char number[50] = { '\0' } ; // Initialize MUST
    char new_number[50] = { '\0' } ; // Initialize MUST
    int sourcebase=0;
    int targetbase=0;
    int length=0;
    int decimal=0;
    int power=0;
    int remainder=0;
    
    
    do { 
           system("cls"); // dont use OS dependent funcitons

         printf("Enter a source base between 2 and 10:");
        scanf_s("%d",&sourcebase);
        if((sourcebase<2||sourcebase>10)){
        printf("Invalid!!!Your source base must be between 2 an 10\n\n");
             system("pause"); // dont use OS dependent functions
        continue;
        }
        printf("Enter a positive number:");

        scanf_s("%s",number,49); // dont know what it does
// it is not a standard C function.
 
        length=strlen(number);

        for(int i=0;i<length;i++){
            if((number[i]<'0')||(number[i]>=sourcebase+'0')){
            printf("Error!!! number cannot be less than zero.\n\n");
                system("pause");
        break;
            }
        
                if (i<length) continue;
        }
        printf("Enter a target base between 2 and 10:");
        scanf_s("%d",&targetbase);
        if((targetbase<2||targetbase>10)){
        printf("Invalid!!!Your target base must be between 2 an 10\n\n");
            system("pause");
        continue;
        }
        break;
        /* Validate User Data*/
    }while(1);
       /* Convert to Decimal*/
    for (int j=length-1; j>=0;--j){
        decimal+=(number[j]-'0')*pow((float)sourcebase,power);
        power++;
        
    } 

// int k=0; 
// WRONG !! if you want to add the remainder at the end of the
// character array you should initilize it with the last index of teh 
// character array and not 0

// Also adding remainder at the end of the array is difficult
// to achieve since the start positions of the char array might go
// wasted and print out junk while printing out the whole array.

// Better start appending the remainder at the start of char array.

       while(decimal>0){

       /* Convert to Target Base*/
     
          remainder=decimal%targetbase; …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heh never worked with any one of those except Perl so I am a bit confused.... Python, LUA, LISP... maybe what I need is a bit of research on my part.. :D

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

Heh people, finally I have been struck by P1K ... oh I mean I have completed by 1000 posts on Daniweb. Feels good. :mrgreen:

With all your members, moderators, super moderators and admins support and friendship, I have in just 5-6 months..

  • reached 1000 posts,
  • 5 dot reputation and a
  • moderator title.

Again, thanks a lot to all you ladies and gentlemen out there and hoping to get your help and support in the near future to make DaniWeb a better place for one and all. (maybe become a super mod some day and start disturbing... err I mean helping one and all.. muwahhha :twisted: )

Thank you everyone and have a nice day.

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

You will find everything here:
http://www.daniweb.com/techtalkforums/thread50370.html

Just be patient, read the whole thread, visit OpenGL links, read the tutorials on how to setup OpenGL and you will be up in no time.

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

Yes, I knew that. But somehow it didnt stop me getting some kind of dialog box. I don't usually trouble with software like that when it is an experiment.

Hmm.. strange.

Don't recall. Do a search for code vlocksin your posts and you will find it. If it was you that mentioned it that is.

Huh !! What is "code vlocksin" ??? And how to search only within my posts ?:mrgreen:

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

You said "crap".

crap1 (krăp)
n.

  1. Excrement.
  2. An act of defecating.
  3. Foolish, deceitful, or boastful language.
  4. Cheap or shoddy material.
  5. Miscellaneous or disorganized items
  6. Insolent talk or behavior.

Now since I am a MOD and its my duty to follow the forum rules, you can very well understand which option given above, describes what I was trying to convey.

I hope you get the point.

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

Please tolerate mine as well.

Yeah no problem, you seem to be a nice guy mister, and I am always in favour of a healthy debate.

Student?

Yes.

And btw even I need money, its so obvious, whenever we talk of something, money is always there. And btw I think you took my personal opinion and what I think as a personal insult. Believe it or not, I am not that kind of a guy who thinks his ego is more than anything else, if you still dont believe me ask the people at C++ forum.

2. So, if we code for the .net framework, we aren't 'real' programmers. We just drag and drop. In this, you are just flame baiting. It's not better than your languages of choice, but to dismiss it as a child's toy is offensive to those of us who make our living coding in it.

Again you took this as personal insult. The things I actually wrote were meant for a student who wanted to know where he should start off. I just wanted to make his start a bit challenging so in the near future he can easily make a transition to rapid prototying ones like .NET. I didnt know my comments would have such widespread impact.

3. I don't know quite how to quote this to make my point. Your last paragraph quoted above states the obvious - many people DO like to take things into their own hands …

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

Thats got Java written all over it.

I think there is a misunderstanding. I was not refering to the indentation but to the fact that the function name was written in all Uppercase letters.

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

To disable the loading of Subversion plugin, goto

Plugins -> Manage Plugins -> uncheck Subversion Plugin -> Restart Codeblocks

Done and done.

PS: When did i mention Code blocks before... I used that term only in the sticky section and just a few posts back. Dont tell me you tried out that thing after seeing my 9.27 post :eek:

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

Naa... its not fancy something. Pretty impresive it is. Very powerful, can be used along with a lot of plugins for power users and so onand yeah very much along the line of Dev C++.

If you have some time at your hand, please see here
http://www.codeblocks.org/

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

Agreed upon conventions are very convenient and can be useful, but in the end they are conventions, not mandates intrinsic to the language. One employer may require one convention and another employer may require another.

I wasnt trying to justify why conventions are important, just trying to prove my previous point.

BTW though conventions are not mandatory, no employer would like to see his employee write variables like:

int CoUnteR ;
string _NaMe__ ;

In the end it depends on the employer whom you are working with, and all employers and companies would like to stick with the standard conventions, so in the end logically it becomes mandatory for you to follow a convention. ;)

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

>>Now I would really like to know who writes functions that way !!!

Placement of the opening curly bracket on the same line as the function definition or the loop control is a standard style. I believe it is used in such notable references as K&R and from past discussions is the favored style of some well respected members of this board.

I wasnt referring to brace placements.

Use of all caps for function names is a bit extreme, IMHO, but not an illogical approach.

Can you quote any logical situation where all caps are used for function names. All caps are a standard ( almost universal std ) for constants and #defines . A function writtein in all caps will confuse each and everyone who sees it, thinking that it is either a macro or constant.

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

But, this is coffee house.

..which I know better than most people.

The "topics" here should be motivation for the conversation. Just a starting theme.

But not trip over the line. There is always a thin line between joke and insult. We are here to see that doesnt happen.

Honestly, did you ever went to a drink with couple of ppl and talk about SINGLE TOPIC?

Those were my near ones and I know what they like and how close friends they are of mine. Everyone here comes from a different part of the globe, different culture, different roots. First get to know the likes and dislikes of people and then make assumptions.

Damn ppl, don't be such tight-a**. (See? I didn't say it.)

Seriously wont be tolerated next time.

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

Don't forget to use the header #include "very_small_violins" then.

Oh what the hell, this is the joke of the century :mrgreen:
Keep it up Mr. Iamthwee

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
void MYFUNCTION(){
}

Now I would really like to know who writes functions that way !!!:eek:

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

Ah... tricky, thanks. Then
to see each character.

Hmm... no its incorrect. Correct one is:

cout << letters[i] <<" appears "<< counter[i] << " times\n";
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Since 48 is the ASCII value of character '0'.

It would be better if you replace 48 in your formula to '0' since it would make more sense and you dont have to remember all the integer equivalents of the different characters. Just using random literals in teh program makes it difficult to understand for others and even for you after some time has elasped.

In short just mysterious literals should be avoided, follow my method and use '0'.

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

Code::Blocks for small projects and Visual Studio for large projects.

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

Oh, thaaaanks- now we've got seven requests for editorial cleanup lined up in the Reported Posts forum. Joy............. :eek: :mrgreen:

Err.. sorry Sir. Couldnt think of anything else, and also the concerned moderators of tech talk were not online.

Would like to know what to do in such cases ?
Thanks in advance.

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

chill moderators

We are here to maintain decordum in the forum. If somenoe tries to poke his nose in someone's affair's and saying out things they shouldnt, its our duty to intervene.

Is Dani still single?

i think dani has a boyfriend doesnt she?

THese things dont pertain to the topic under consideration and are not appropropirate unless the person under consideration explicitly assents to it.

were just joking around ok, you dont need to punish aneyone

... which we haven't coz we are nice people :mrgreen: and feel everyone must be given a chance since mistakes do happen. ;)

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

Ah... yes thank you "Father" :D

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

Loops are a very important constructs in programming.

Imagine you want to gather data from 100 clients and put it in an array of client data. Imagine doing that without loop:

cout << "Enter data of client 1: " ;
cin >> record[0] ;
cout << "Enter data of client 2: " ;
cin >> record[1] ;
cout << "Enter data of client 3: " ;
cin >> record[2] ;

// ... and so on till 100

With loops its like:

for( int i = 0; i < 100; ++i )
{
    cout << "Enter data of client " << i + 1 << ": " ;
    cin >> record[i] ;
}
// end of data gathering phase

Hope you get the drift...

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

Okay, the thing is that moderataors arent allowed to post code to help people out, its against the rules so I will just give you a short tutorial.

For learning about loops go here
http://www.cprogramming.com/tutorial/c/lesson3.html

For learning about accepting user input go here
http://www.cprogramming.com/tutorial/string.html

For use of toupper function go here
http://www.cprogramming.com/fod/toupper.html

Create a program from start with the help of these tutorials, adding feature one by one so that you dont mess it up, and then post your new program.

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

Did you read the algo I posted above? It exactly describes how you should go about finding freqency count.

And btw is there any restriction on using in built functions in your assignment, coz there is a function toupper( ) which accepts a character and returns its uppercase. So you should use that function instead of writing your own.

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

Hmm.. ok I will give you a simple algo, you attempt it and post your code if you get stuck:

  • Create a variable character count which counts the non uppercase chars and initialize it to zero.
  • Create an array of 26 integers and initialize it to zero. This array will keep track of the uppercase alphabet count.
  • Accept the input ( uppercase and other characters ) from the user into a array of characters ( C style string ).
  • Loop through the character array from the start ( i.e. position 0 ) till the end of string is encountered ( '\0' ).
  • For each character use the isupper( ) function to check whether the character is upper case.
  • If yes then increment the value corresponding to that character in the array. (Hint characters are actually integer values, so manipulate them to obtain the correct array index.
  • IF the char is not uppercase then just increment the count var.

Hope it helped, bye.

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

Hey. Dani. I think it has something to do with

tags within

tags. Because once I delete the '=c' part, the post is displayed.

But this wasnt the case with Mr. Iamthwee's post since he had posted simple text.

So i dont think only the code tags are responsible for this.

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

The same thing happened with Mr. Iamthwee some days back. I had to merge the blank post and his subsequent post.

This has happened some times with me but i thought it was nothing, just some minor problem, but now if everyone is experiencing it...

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

Bah.. silly me.

Thanks Wolfie :D

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

Err.. maybe i should have been explicit..

I can modify it as well as view it. First it was not visible but when i pressed the edit button and saved it, it became visible.

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

I'm trying to turn this part into a function into my code

But where is the function in your code ... I dont see it.

Post the updated code.

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

But i can modify it Wolfie, see the post for it.

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

Oh my god I'must be losing it. Your rigth offcourse, maybe I should stop drinking or something....

Heh happens buddy, it frequently happens. :cheesy:

The main thing is you admitted it which most people dont.

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

Also, you have to bribe the Super Mods big time. That's the only way they even consider you...either that or I've been ripped.

lol good one mate.

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

But how to use it ?

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

Only when you want to reply to a post which has quoted some other post, the button gets used.

Like:

I wonder what the button does

It does exactly what i said right now

Now try to multi quote my post and it will happen

Hope it helped, bye.

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

What's wordstream.h linkedlist.h?

Please label which one is which for clarity

I think he hasn't posted those files.

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

Yeah just like your previous functions... declare the prototype at the start of the program and write the function defination at the end.

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

What to add at the end ?
What have you decided, to use inbuilt functions or to make your own function?
First specify.

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

Hmm.. so you will obviously need a sorting algo..
If inbuilt algorithm will do, then look HERE

Otherwise you need to implement one of your own. A simple one you can get HERE

edit: Dont tell me you are usign the compiler of doomsday i.e. Turbo C ??

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

getline() throws away the \n null character at the end of a string and therefore makes a mess when trying to fluch the buffer.

More surprises...

'\n' is a newline character, not null character ( '\0' )

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

I have to agree. Guys, this is an online collaborative community and we take pride that this is great place for everyone. Such language and topics will not be tolerated. Please keep this in mind

Hoping you will infract such posts and members before I do :D

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

I find talking trees sacrilegious to my utilitarian nihilism. :D

Whoa, now those are some cool games you have come up with.... :mrgreen:

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

See the thing is that there are different moderators for different forums, I am a moderator of the software development forum which deals with programming languages.

For getting your post edited just press the "flag bad post" for all the posts which you have colored and give the reason as " I request the concerned moderator to please revert the colors back to normal. Thanks a lot for your help."

That should get the job done.

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

Naa dont bother, maybe the duration till which the edit post option appears has expired, just request the moderators to change the color to defaut and they will do it for you.