user87354: I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code.
for example ,
instead of including some libraries and write the code like this..
#include "arduino.h"


int main(){

    pinMode(13, OUTPUT);

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

We have to write it using functions defined in arduino.
void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.
*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

user10794: Arduino IDE uses C++ not C.
You don't have to use setup and loop. This is a valid Arduino sketch:
#include <Arduino.h>

int main ()
  {
  init ();  // initialize timers
  Serial.begin (115200);
  Serial.println ("Hello, world");
  Serial.flush (); // let serial printing finish
  }  // end of main


But I would like to know what is the best way.

The way that works best for you. The IDE gives you some convenience functions. You don't have to use them. You can look at the datasheet and directly address the hardware registers.
See here for a few more details.

87354: <p>I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code.
for example ,
instead of including some libraries and write the code like this..</p>
<pre><code>#include &quot;arduino.h&quot;


int main(){

    pinMode(13, OUTPUT);

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}
</code></pre>
<p>We have to write it using functions defined in arduino.</p>
<pre><code>void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}
</code></pre>
<p>But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.</p>
<p>*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.</p>
 10794: <p>Arduino IDE uses C++ not C.</p>
<p>You don't <strong>have</strong> to use <code>setup</code> and <code>loop</code>. This is a valid Arduino sketch:</p>
<pre><code>#include &lt;Arduino.h&gt;

int main ()
  {
  init ();  // initialize timers
  Serial.begin (115200);
  Serial.println (&quot;Hello, world&quot;);
  Serial.flush (); // let serial printing finish
  }  // end of main
</code></pre>
<blockquote>
<p>But I would like to know what is the best way.</p>
</blockquote>
<p>The way that works best for you. The IDE gives you some convenience functions. You don't have to use them. You can look at the datasheet and directly address the hardware registers.</p>
<p>See <a href="http://www.gammon.com.au/forum/bbshowpost.php?id=12625" rel="nofollow noreferrer">here</a> for a few more details.</p>
