Thread: help in transfoming C++ code into regular ansi C..

  1. #16
    Join Date
    Oct 2008
    Because this c++ code is a complete solution to my problem .
    Unfortunately i cant see the logic of it.
    and there are too many commands which are needed to be replaced.

    and i now very little c++.

  2. #17
    Join Date
    Oct 2007
    Inside my computer
    And now you have erased everything C++, and all that's left is C. Yet you still struggle.
    I'm just saying - I don't think this is a good idea!
    If you have an assignment, why should you hunt for solutions when you should write the code yourself?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Quote Originally Posted by transgalactic2
    Because this c++ code is a complete solution to my problem .
    Unfortunately i cant see the logic of it.
    So, you happened to find this C++ program somewhere, and basically want to copy it, but you have to hand in a C program compilable under C90.

    Clearly, your assignment is not about transforming a C++ program into a C program, which was what I thought you were trying to do. I believe others who contributed to this thread thought the same. Rather, the aim was for you to develop a solution to the problem and implement it in C.

    What you should be asking for is help in understanding the solution that you have found so that you can re-implement it in C. Mechanically translating the solution from C++ to C is tantamount to plagarism, and arguably as bad as finding a solution in C and handing it up as your own work. You may even be guilty of copyright infringement if you do not have permission to copy and make a derivative work.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #19
    Join Date
    Oct 2008
    It was written in c++ specifically for my problem.
    I did not steal it.
    I have built some thing close.

    But it gives me the right a right pair numbers many times .
    for input 54 it gives me 12 42 12 42 12 42 (it should give me only one pair) 12 42
    and it doesnt give me the result for 53 52 .. 1
    (whether they are a sum of two abounded numbers)

    i tried to trace with a debugger but i cant see the problem
    #include <stdio.h>
    int  main(){
        int num;
        int index,tndex,kndex,jndex;
        int flag_1,flag_2,same_num;
        int sum;
        int smallest,smallest_ever,smallest_ever_2;
        printf("enter number\n");
        for(index=1;index<num;index++){ //start for main number
                        for(jndex=1;jndex<tndex;jndex++){//start abbondence check for first num (tndex)
                            if (tndex%jndex==0){
                            if (tndex<sum){
                        }//end abbondence check for first num
                        for(jndex=1;jndex<kndex;jndex++){//start abbondence check for second num (kndex)
                            if (kndex%jndex==0){
                         if (kndex<sum){
                        }//end abbondence check for first num
                        if ((flag_2==1)&&(flag_1==1)){  //start flag check
                            if (kndex>=tndex){
                                if ((smallest<smallest_ever)&&(smallest>1)){
                                if ((smallest<smallest_ever)&&(smallest>1)){
                             printf("%d %d\n",smallest_ever,smallest_ever_2);
                        }//end flag check
      return 0;
    }//end main
    Last edited by transgalactic2; 12-08-2008 at 04:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM