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

zooming -> microscope

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

you get Bill Gates

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

..and to top it all

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

Please explain the problem clearly so that we can help you out. Post your entire code along with the problems you are encountering.. whether it is compile time error or run time error or the program is not working as expectd and so on. Maybe then we would be able to help you out.

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

4.8
.
Write C++ statements to accomplish each of the following:
a) Display the value of the seventh element of character array f.
b) Input a value into element 4 of single-subscripted floating-point array b.
c) Initialize each of the 5 elements of single-subscripted integer array g to 8.
d) Total and print the elements of floating-point array c of 100 elements.
e) Copy array a into the first portion of array b. Assume double a[ 11], b[ 34];
f) Determine and print the smallest and largest values contained in 99-element floating-point array w.

All the parts here require you to create new arrays and i think are not dependent on each other.

Part C requires you to create an INTEGER array "g" and initialize all the five elements to 8. As i can see from your attempt you still havent completely grasped the syntax so you need to work on it.

Part d requires you to create an FLOATING POINT array "c" of 100 elements and add all the elements up.

Part e requires copying value from array "a" to array "b" with the given indices.

Part f require you to find the smallest and largest number in the array having 100 floating point numbers and is named "w".

As far as part c is concerned i will give you small snippet and you can do the rest of the parts yourself.

#include <iostream>
using …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What have you attempted till now, post it here so that we can set your logic right and make you understand things more clearly.

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

up the FBI

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

Lord of the Rings : Return of the king

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

Ghost Riders

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

You get a huge electricity bill.

I put in Intel Duo Core 2.

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

mud boggers -> turbochargers ;)

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

Dont know what exactly you want but if you want some tuts on interfacign MySQL and C you can visit some of the links given below:

http://www.tol.it/doc/MySQL/
http://dev.mysql.com/doc/refman/5.0/en/c.html

Hope it helped, bye

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

Not sure whether it would work for TurboC and the old command.com shell, but you could try creating the command using double quotes to handle filenames with spaces. Don't know what will happen for long file names though.

e.g.

copy [B]"[/B]c:\yserver.txt[B]"[/B] [B]"[/B]c:\documents and settings\luffy-san\desktop\tcp1241_assignment3\lecture notes\server.txt[B]"[/B]

Yep it works. Dont know where you found out about this one but this sure is informative, hats off (and of course rep)to you.

Your friend,

~s.o.s~

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

Hmm looks like your basics are a bit err.. shaky. You got most of the syntax there wrong. Why not revist the basics by learning something about C++ with good books. Some tuts here

I think maybe u looking for something like this:

#include <iostream>
using namespace std ;

int main (void)
{
    const int size = 6 ;
    char my_array [size] =  {'a', 'b', 'c', 'd', 'e', 'f' } ;
    cout << "\nThe value of 6th element is " << my_array [5] ;
    cin.get ();
    return 0 ;
}

Hope it helped, bye.

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

There is nothing wrong with your program, it is the command which is incorrect. Do some research on the DOS Copy command to find out the valid commands and the format of the command. Look at the link which i had given in my 4th or 5th post on the previous page.

Hope it helped, bye.

@Mr. Salem : What is the difference if the compiler is 16 bit or 32 bit since the "copy" command which is executed in DOS mode runs in 16 bit. Try out the commands written by the guy in the DOS window without the program, jsut type it and still it doesnt work so i guess no mistake of teh compiler.
But then again maybe i am wrong somewhere, please let me know where it is?

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

What kind of optimization do you want to perform on this code, performance wise or lengthwise ? Please be more specific.

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

I get the following error on the first line of my array...

" syntax error before `}' token "

My eyes are about to fall out of my skull. Can someone take a look for me, everything seems to be fine, but maybe I'm blind.


Here is the code in question...

int bin[26][5]={
                  {0,0,0,0,0},(0,0,0,0,1},{0,0,0,1,0},{0,0,0,1,1},{0,0,1,0,0},{0,0,1,0,1},
                  {0,0,1,1,0},{0,0,1,1,1},{0,1,0,0,0},{0,1,0,0,1},{0,1,0,1,0},{0,1,0,1,1},
                  {0,1,1,0,0},{0,1,1,0,1},{0,1,1,1,0},{0,1,1,1,1},{1,0,0,0,0},{1,0,0,0,1},
                  {1,0,0,1,0},{1,0,0,1,1},{1,0,1,0,0},{1,0,1,0,1},{1,0,1,1,0},{1,0,1,1,1},
                  {1,1,0,0,0},{1,1,0,0,1}
                  };

The thing marked in red in a round brace which should be replced by curly braces.

Hope it helped, bye.

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

The point that if you try to keep 3 bytes (24 bits) for the string command, the last byte will be taken up by the null terminator '\0' and your command will have only two words.

Why dont you use the commands internal representation as that of hexadecimal type and convert the command typed by user in the string form to the hexadecimal type and store it in the structure.

Hope it helped, bye.

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

Welcome to the forums and btw it is a rule here that you should first post your attempt or your code to get help from someone else. Just demanding the code will not fetch a lot of help.

Still since this is your first post i will let it pass. Maybe you can look here for some example:

http://developer.mimer.com/print_result.tml?typ=1&id=1
http://www.physiol.ox.ac.uk/Computing/Online_Documentation/postgresql/ecpg.html

Hope it helped, bye.

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

Glad we could be of assistance and most of the credit of this problem solved goes to Mr. Salem for pointing out that it was actually the command string which was getting messed up, I just picked up his idea and completed it for you.

Best of luck.

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

Windows works with backslashes "\" and forward slashes "/" but you better use Backslashes.

And also looking at your "command string" dump i can clearly see the problem. YOu are passing something like "copyA.txt B.txt" which is not the correct syntax fro the DOS copy command.

The actual syntax is "copy source dest" with spaces present in between. You can find the syntax for all commands here
http://www.easydos.com/copy.html

For testing purpose try out inputting
YServer.txt as the first input and server.txt as the second input and watch what output is displayed.

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

So where is your int main (void) function and what problems are you facing with this code, and if facing compile time problems mark the line which flags the error in red so taht we can see it and if run time error then describe it.

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

add

char a='"';
strcat(a, copier);
strcat(copier, a);

hahaha.. compile error!

Umm... buddy, what exactly are you trying to do. strcat funtion expects you to supply both parameters as char* ie char pointers and you supplying it a char.

You can get its prototype here: http://www.cppreference.com

Post your complete program from start to finish with the header files and then maybe i could pinpoint the mistake.

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

I dont get you...
Are you saying even after making the changes you get a syntax error ???

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
cin.ignore();
cout << "Enter lecture notes/tutorials location.\n";
cout << "e.g C:/Lecture Notes/lecture01.ppt";
cout << ">>>";
getline(cin,lectut_loca);
cout << "Enter lecture notes/tutorials name: ";
cout << "e.g lecture01.ppt";
cout << ">>>";
getline(cin,lectut_name);
string copy = "copy";
 copier = copy + " " + lectut_loca + " " + lectut_name;
// using variable before declaring it is not allowed in your case copier.

 const char *copier; // initialisation of const variables must be done 
                            // during declaration intself eg. const int i = 8 ;
 cout << copier;
 getch(); // getch() is non portable use cin.get ()
system(copier);
cout << "\nLecture notes/tutorials added.";

what should i do?

Look at the things i have mentioned above.
And maybe you should look at this simple expample.

string my_copy = "copy" ;
my_copy += " " + lectut_loca + " " + lectut_name ;
const char* copier = my_copy.c_str() ;
system (copier) ;

Hope ti helped, bye.

PS: looks like you are trying to implement the copy function of DOS.
;)

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

There is actually no need to create an array, the problem can be solved using just two "loops". Dont use the function "clrscr()" since it kills program portability and it is a non standard function. If possible try to move from the age old turbo compiler to the list of new compilers provided in the thread mentioned below.

And as far as the thing that you are a newbie is concerned, if you are in need of tutorials, look at the sticky at the top of the forum named "Starting C", it can help you a lot.

Also here is a sample of how you can do it and i wont tell you how to solve the rest of them, you need to think about them.

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

int main (void)
{
    int i, j ;

    for (i = 5; i > 0; --i)
    {
        for (j = i; j > 0; --j)
        {
            printf ("%d", i) ;
        }
        putchar ('\n') ;
    }
    getchar () ;
    return 0 ;
}

Hope it helped, bye.

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

Can anyone help me w/ this....help me make a program of pascal triangle

A well detailed example here;

http://www.daniweb.com/techtalkforums/thread49775.html

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

Hi im new here...i am only an high school student, i hav a problem on my this output...im using turbo c, can u help me with ths?? i cant get it...pls help help me

Please post your code so we can what the problem is and point it out to you.

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

Maybe you can try out something of this sort and make it more robust and suiting to your own purpose.

using namespace std;
int main()
{
     int number=10;
     int your_number;
     char answer = 'y';

    do
    {
        cout<< "\nguess the number: ";
        cin >> your_number;

        if(number == your_number)
        {
            cout<<"\nCongrats!";
            cout<<"\nWant to try again? ";
            cin >> answer;
        }
       else if (your_number > number)
       {
            cout << "\nYour guess is a bit too high " ;
        }
       else if (your_number < number)
       {
            cout << "\nYour guess is a bit too low " ;
       }
    }
    while (answer == 'y');
    return 0;
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <stdio.h>
#include <string.h>
char* string(char *str);
int main()
{
      printf("%s\n ",string(" in this method "));
      getchar();
      return 0;
}
 char string(char *str4) // the char should be char*
{
     char str[25]  = "How";
     char str2[25] = " do I ";
     char str3[25] = " return a string";
     strcat(str,str2);    //append str2  to str and return str
return strcat(str,str3); // you are returning the addr of local variable
                                 // whose scope is limited to this function.
}

Dont return the addr of a local variable since local vars of a function are placed on the stack and are destroyed when the function returns.

Better pass the string which you want to be modified to the function.
Something like this:

#include <stdio.h>
#include <string.h>
char* my_string (char *src, char* dest);
int main()
{
    char str[25] = {'\0'} ;
    printf("%s\n ",my_string(" in this method ", str));
    getchar();
    return 0;
}

char* my_string(char *src, char* dest)
{
    char str1[25] = "How";
    char str2[25] = " do I ";
    char str3[25] = " return a string";
    strcat(dest,str1);   //append str2 to str and return str
    strcat(dest,str2);
    strcat(dest,str3);
    return dest ;
}

Hope it helped, bye.

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

Hmm as such its very vague coz u see both the binary and the application along with shared object resides at your own PC and even you uploaded it here no one would have the time to go through it. Be a bit more specific and try localising the problem a bit.

Best of luck for the project.

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

Yes Java is supposed to work on all platforms since its portable and compiles the program in byte code which runs on its virtual machine. So as long as the abstraction is present you need not worry.

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

Well here is the general techinique used to avoid the pitfalls of scanf.
Take a look at this code iif you are really interested in learing something new.

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


int main (void)
{
    char buffer [BUFSIZ] ;
    float years, days;
    printf ("Please type your age in years: ");
    fgets (buffer, BUFSIZ, stdin) ;
    if ( buffer [strlen (buffer)] == '\n')
        buffer [strlen(buffer)] = '\0' ;
    years = atof (buffer) ;
    days = years * 365;
    printf ("\nYou are %.0f days old.\n", days);
    getchar () ;

    return 0 ;
}

Hope it helped,bye.

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

Better than using scanf which is a pretty complicated function which leaves the input stream dirty try out the alternative functions fgets along with atoi to take the input from user. For the function prototypes look here:
http://www.cplusplus.com

And why are you using the age old Turbo Compiler? If you can, try to install a better IDE as well as a compiler.

The list of all the new compilers and free IDE can be found in the sticky at the top of the C++ forum in "Starting C".

Hope it helped, bye.

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

When I compiled the follwing code snippet, it compiled without any error.
My question is if it is allowed to declare char fields inside a structure, then how can I store character string in that variable(we can not use functoins like strcpy:-| ).
OR
Is it not allowed to declare char inside?

#include <stdio.h>
#include <string.h>
int main() {
        struct aaa {
                unsigned int  a : 4;
                unsigned char  b : 24;
                unsigned int  c : 4;
                };
        struct aaa *pqr;
        }

Thanks

Hey buddy, the above code doesnt even compile since the size of the second variable (which is of type char) exceeds its limit since it has size 8 bits and u are trying to give it 24 bits.

And if you want to store something is char why not just assign it like normal variables.

Maybe you want something like:

typedef struct aaa {
    unsigned int  a : 4;
    unsigned char  b[24];
    unsigned int  c : 4;
}myStruct ;

int main (void)
{
    myStruct obj ;
    strncpy (obj.b, "abcdefghijklmnopqrstuvwxyz", 24) ;
    printf ("%s", obj.b) ;

    return 0 ;
}

Hope it helped, bye.

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

What if you were told to use arrays to solve this?

Dont resurrect dead threads. Take a look at the date and time of the thread before posting.

Mr. MOD please close this thread or delete the above two posts.

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

Though i dont know what exactly blackjack is but i think this is wat u want.

#include <iostream>
using namespace::std;

int main()
{
    char cards[13]={'2','3','4','5','6','7','8','9','0','J','Q','K','A'};
    char deck [260] ;    
    for (int i=0; i< 260; i++)
         deck[i] = cards [i % 13];        
        
    for (int i = 0; i < 260; ++i)
        cout << i << "  " << deck [i] << endl;

    cin.get () ; // use this funciton for making the screen stop
    //system("PAUSE"); dont use OS functions
    return 0;
}

Sorry if this is not what you were looking for.

hoosier23 commented: nice! +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want someone to help you, it would be really better if you err... made your problem description a bit brief giving us what you have so far gathered about the problem and what have u decided till now.

Try to make a skeleton or the framework for your project writing down only the basic things and then post the problem in which you are stuck on. Maybe then we would be able to help you a bit.

Hope it helped, bye.

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

If you want a third party library for interfacing between C++ and TCL then maybe you should look here
http://cpptcl.sourceforge.net/

As for your second part of the question you havent as such mentionend what exactly is ICE otherwise i would have definately said something.

Hope it helped, bye.

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

I think you can execute whatever project you want to create with any language, and sice i havent used a lot of C# i dont know the specifics like if it has networking support libraries. But still try reading the documentation and some good tuts on C# and see if they mention something regarding networking and all that.

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

Why not try out Java, since it is really good at such things and with the inbuilt excellent GUI support it would be an added advantage ?
Even Python along with one of its graphic toolkits can be used for the purpose.

Also it depends on the kind of experience you have with these languages coz without that such a vast project would remain a pipe dream.

~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

>>cout<< ((A*)3)->get() << endl;

This is using undefined behavor techniques. 3 isprobably not a valid address for an object of type class A.

Oh yes and i overlooked this particular thing. Thanks for pointing it out Mr. Dragon. Maybe this is one of those quizzies questions where you are asked to predict the output of the code snippet.

Rule:
1. Before using any pointer dont forget to allocate memory to it or to point it to an existing object. Hence when using a pointer better ground it (make it NULL) so that you dont end up using it by mistake.

2. Delete only those pointers for those you have explicitly allocated memory using the "new" stmt. Forgettting to free the memory results in what is known as a memory leak.

Hope it helped, bye.

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

Some of the tutorials for those interested in the OpenGL API programming using C.

Beginner Opengl tuts

http://www.codecolony.de/opengl.htm

http://www.zeuscmd.com/index.php

http://www.sulaco.co.za/tut.htm


Hope it helped, bye.

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

please help me understand the folowing code....

class A {
      int a;
  public:
     A() : a ( 0 ) {} 
     int get()  {
          cout << "Hello WOrld " << endl;
          return 0;
     }
 };
 
  int main( int argc, char** argv )
 {
      cout<< ((A*)3)->get() << endl;
       return 0;
 }

The thing is that when an object is created, its constructor is called but not when the object pointer is created which is the thing in your case. (please get this verified, havent done C++ in quite a while)

So as a pointer to object is created, you dont specifically allocate any memory, the class variable doesnt exist. So as soon as the function si encountered, the "cout" stmt is executed and prints out the output but when encounters the reutrn a stmt, there is as such no "a" to which the object points to since no memory has been allocated.

In the end, yes since the memory is not allocated for the pointer and neither does it point to any object hence an execption is generated. Returning something which doesnt exist is not a very good thing ;)
And btw your code doesnt technically run as an run time exception is generated, there is a difference you know ;)

Hope it helped, bye.

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

I think maybe you are looking for function pointers which can decide which function to execute dynamically depending on the type of input by the user or triggered by some condition in the program. So if you have ten functions in a file "functions.c" with the same signatures and return types and you want to call one of those functions depeding on the input of the user, you can declare a function pointer which can moulded into any function call on the fly.

More info can be found here:
http://theory.uwinnipeg.ca/programming/node86.html
http://www.newty.de/fpt/fpt.html
http://www.eskimo.com/~scs/cclass/int/sx10a.html
http://publications.gbdirect.co.uk/c_book/chapter5/function_pointers.html

Hope it helped, bye.

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

Maybe this link will help you in formulating the problem statement
http://en.wikipedia.org/wiki/Cluedo

First decide on the kind of depth you want to achieve in your game, how your game is goign to interact with the user, the input received by the game and the output. Then make a rough sketch or an algorithm on how are you going to plan the implementation. If using C++ decide on the classes you think are important to the domain and the kind of variables present in the classes.

Move from most logical solution to the most indepth solution, split the implementation into logical modules. Start with the highest abstraction and then decide on the implemetation details of each chunk or module of the hierarchy. Good design methodology and designing is the key to handling projects and if done wisely then the implementation just reduces to the mechanical process of code writing and testing.

HOpe it helped, bye.

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

Maybe something likie this is what you are looking for:

#include <iostream>
using namespace std ;

bool checker (int number, int& total)
{
    if (number == 0)
    {
        return false;
    }
    else
    {
        if (number%2 == 1)
            cout << number << " is odd" << endl;
        else
            cout << number << " is even" << endl;
        total += number;
        return true ;
    }
}

int main (void)
{

    int number_buffer = 0, total = 0 ;
    cin >> number_buffer;

    while ( checker (number_buffer, total) )
        cin >> number_buffer ;

    cout << "Total: " << total;
    return 0;
}

My output:

1
1 is odd
2
2 is even
3
3 is odd
4
4 is even
5
5 is odd
0
Total: 15
Press ENTER to continue.

Hope it helped, bye.

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

Maybe something like this is what you are looking for

int main (void)
{
    int i, j ;
    char num_string[] = "1 234 23 45" ;
    char tmp [2] = {'\0', '\0'} ;
    int length = strlen (num_string) ;
    int* values = (int*) malloc (sizeof (int) * length) ;

    for ( i = 0, j = 0; i < length; ++i)
    {
        if ( isdigit (num_string[i] ) )
        {
            tmp [0] = num_string [i] ;
            values [j++] = atoi (tmp) ;
        }
    }

    printf ("\nThe string: %s", num_string) ;
    printf ("\nThe integer array which results is: ") ;
    for ( i = 0; i < j; ++i)
        printf (" %d ", values[i]) ;

    return 0 ;
}

My output is:

The string: 1 234 23 45
The integer array which results is: 1 2 3 4 2 3 4 5
Press ENTER to continue.

Hope it helped , bye.

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

Maybe you would want to have a look here for some OS related resources. It features the implementation of a bankers algo and some of the other advanced topics overview which should help you in deciding which project to choose.
http://www.bernstein-plus-sons.com/.dowling/CSC080/

Hope it helped, bye.