473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to compile this C Code in Dev-C++??

JS
I have done the following: New Project -> Console Application -> C Project.

Then I get the following text:

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

int main(int argc, char *argv[])
{

system("PAUSE");
return 0;
}
But where do I write my own C code? I have written the following code:

void c(unsigned int n) {
while (n > 1)
if ((n & 1) == 0)
n = n/2;
else
n = 3 * n + 1;
}

But where should I put it and how do I compile it?

js

Jul 22 '05 #1
6 1894
* JS:
I have done the following: New Project -> Console Application -> C Project.


Off-topic on two grounds: (1) this is a C++ group, and questions about
pure C are off-topic, and (2) this is a C++ group, and platform-specific
questions are off-topic.

Due to (2) the question is also off-topic in [comp.lang.c].

Try [alt.comp.lang.learn.c.c++]; you might be well advised to first
check out the FAQ for that group (Google).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2
JS wrote:
I have done the following: New Project -> Console Application -> C Project.

Then I get the following text:

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

int main(int argc, char *argv[])
{

system("PAUSE");
return 0;
}
But where do I write my own C code? I have written the following code:

void c(unsigned int n) {
while (n > 1)
if ((n & 1) == 0)
n = n/2;
else
n = 3 * n + 1;
}

But where should I put it and how do I compile it?


I think you're in a wrong newsgroup, twice. First, because this is not
a C newsgroup, but a C++ newsgroup. comp.lang.c is just down the hall,
to the left. Second, because you probably need help with using your IDE
and not with the language. I don't know a newsgroup for it. Isn't there
an online (Web) forum for Dev-C++ somewhere?

V
Jul 22 '05 #3

"JS" <dsa.@asdf.com> wrote in message news:cn**********@news.net.uni-c.dk...
I have done the following: New Project -> Console Application -> C Project.

Then I get the following text:

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

int main(int argc, char *argv[])
{

system("PAUSE");
return 0;
}
But where do I write my own C code? I have written the following code:

void c(unsigned int n) {
while (n > 1)
if ((n & 1) == 0)
n = n/2;
else
n = 3 * n + 1;
}

But where should I put it and how do I compile it?


As you've been told already, you should ask C questions in a C newsgroup.

But, this could just as easily be a C++ question, so I'll give you some
pointers:

First, one place to put that function is just above your main() function.
Then, you can call it from main(). There are other ways to arrange
programs, which you'll need to learn, but this will work for now.

Second, leaving aside analysis of what the function c does internally, you
should note that anything that it does to n internally will not be relected
back to the variable that is passed to the function, because n, in that
function, is simply a local copy of the value passed in. That's because you
passed it "by value". If you want to actually change the value that was
passed in (from main, for example), you'll need to pass it "by reference".

-Howard

Jul 22 '05 #4
JS wrote:
I have done the following: New Project -> Console Application -> C
Project.

Then I get the following text:

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

int main(int argc, char *argv[])
{

system("PAUSE");
return 0;
}
But where do I write my own C code? I have written the following code:

void c(unsigned int n) {
while (n > 1)
if ((n & 1) == 0)
n = n/2;
else
n = 3 * n + 1;
}

But where should I put it and how do I compile it?

What textbook are you using that doesn't explain how a program in
structured?


Brian
Jul 22 '05 #5

"JS" <dsa.@asdf.com> skrev i meddelandet
news:cn**********@news.net.uni-c.dk...
I have done the following: New Project -> Console Application -> C Project.

Then I get the following text:

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

int main(int argc, char *argv[])
{

system("PAUSE");
return 0;
}
But where do I write my own C code? I have written the following code:

void c(unsigned int n) {
while (n > 1)
if ((n & 1) == 0)
n = n/2;
else
n = 3 * n + 1;
}

But where should I put it and how do I compile it?

js


Try this forum
http://sourceforge.net/forum/forum.php?forum_id=48211
Jul 22 '05 #6
JS
Sorry for my offtopic post but I am totally new to C/C++/Pure C. But thank
you for the guidelines I will follow some of the advises you gave me.

js
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Zach | last post by:
Using Dev-C++ 4.9.8.5 I get error: Compiler: Default compiler Executing g++.exe... g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cpp" -o...
1
by: Dom | last post by:
I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no...
5
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
13
by: developer | last post by:
re-compile under dev -c++ bloodshed. can u help ? #include<dos.h> #include<process.h> #include<io.h> #include<stdio.h> #define STROBE 0x01
10
by: Arno R | last post by:
Hi all, Is it possible to execute a command like 'CompileAndSaveAll' at runtime? In a new app I use a codelibrary. (The app is still changing, codelib also) I add this lib to the references at...
2
mikejfe
by: mikejfe | last post by:
Hi all. I've written a program that dynamically allocates memory for a 3dim array, reads a file into that array, does some stuff to the data in the array and then outputs the array to a file. I...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
2
by: SamuelXiao | last post by:
Here is the error, and the program run no problem in VC++; Compiler: Default compiler Building Makefile: "H:\CS2332\Summer\STL001\Makefile.win" Executing make... make.exe -f...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.