Thread: Writing A Program

  1. #1
    Registered User
    Join Date
    Oct 2006

    Writing A Program

    Well, I am fairly new to C++ but I have written a few small programs. Since I do not know how to save it so i can see if it works, i guess I am asking how to do it. Because I want to be able to use what i creat, no matter how small. ANd to make sure i did it right.

    SO what do i save it as to be able to use teh program?

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Portland, Or
    You want to compile it I assume. How about looking at the tutorials on this site...

  3. #3
    Registered User
    Join Date
    Mar 2006
    You can save any C++ program as a simple text file. Most people use .cpp as the extension (and .c for C programs), but I've seen .cxx and .cc files before.

    You'll need to compile the program -- translate it from C++ to the computer's internal language -- by using a compiler. Dev-C++ includes the good MinGW Windows compiler, as well as a beginner-friendly interface; most Unix systems come with a default compiler I think.
    #include <stdio.h>
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001

    Be patient….

    Installing, configuring, and learning to use a compiler/IDE can be tricky. Hopefully, everything will go smoothly, but don’t get too frustrated if it takes you half a day. If you do choose the Dev-C++ compiler, there are some instructions here..

    I have written a few small programs…
    Whenever you install a new compiler, you should always try-out a simple "Hello World" program first.

    In fact, it’s a good idea to start your “real program” as little “Hello World” type program. …Add one or two lines of code, re-compile and test-run. Continue this way ‘till your program is done. One of the most common beginner mistakes is to write the whole program before compiling. You can end-up with so many compiler errors, that you don’t know where to start debugging.

    Expert programmers use the same approach. They write small parts of the program at a time (of course, more than one or two lines ), testing the small parts as they develop the program.

    This technique takes some practice, because you have to add lines to your program in a way that allows the incomplete program to compile, and so that it tells you something when you run it.
    Last edited by DougDbug; 10-06-2006 at 12:28 PM.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Most people use .cpp as the extension (and .c for C programs), but I've seen .cxx and .cc files before.
    I've also heard of .c++ and .C for case insensitive systems.

    To compile a simple Hello World program in Dev-C++:
    1. Launch Dev-C++.
    2. Create a new file (probably CTRL-N).
    3. There should be a default program typed up. You can try it or
      #include <iostream>
      using namespace std;
      int main() {
          cout << "Hello, World!" << endl;
          return 0;
    4. Choose Compile in the Compile menu (CTRL-F9, I think).
    5. Choose Run in the Compile menu (CTRL-F10, I think).

    Dev-C++ also has a compile and run command; I belive it's F9.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing a program to make a calendar
    By Northstar in forum C Programming
    Replies: 17
    Last Post: 11-07-2007, 11:34 AM
  2. writing a calendar program help please!!!
    By Newbie2006 in forum C Programming
    Replies: 7
    Last Post: 11-20-2002, 07:36 PM
  3. Replies: 5
    Last Post: 11-19-2002, 09:36 PM
  4. Help with a file writing program
    By pritesh in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 01:56 AM