online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { FILE *fpt=fopen("/tmp/abc123", "w"); fputs("0.19552015426254446,-0.051836107230205146,21.379749020857663\n0.7195525890106259,-0.5452562855257107,21.331743987207645\n1.2072363029752535,-0.21336032597717383,21.438289125053675\n-0.020675873316021207,0.2731901800074777,20.739123209504836\n-0.8790226875122183,1.2474975667063313,20.578346601967855\n-0.5217034504419512,-0.4980369712105052,20.00244384380822\n2.2489785282792134,0.5682653114435557,19.549306519479565\n-0.027506515907421786,-0.9182244477724955,19.98208207978958\n-0.21962706283382064,0.22912752828968258,20.53212170587036\n-0.5033857802067455,-1.6445027985612786,21.325208649452172\n0.9140957378991068,-0.13114615200654922,21.588932968893253\n-0.11557960317803097,-1.9518611383870212,22.714164116530416\n-0.6620111925335741,-1.5772969568335053,23.91749412538763\n0.8361943655103091,0.9222427201221164,25.744537267520595\n0.13944639789898589,-0.5207228645645874,27.71955793831022\n-0.06665475451699279,0.1297874895128453,29.787205977126064\n-0.8161890953695217,0.2541065345027374,31.735383337523288\n-0.14707887875113967,-0.3304426361158686,33.17431365892704\n-1.184297891706932,-0.9653395154952273,33.4\n-0.6039725576302319,-0.1790797537237404,32.43067305452768\n-0.360178236071616,0.43825783201750795,30.778802097567823\n0.6182701227423395,-1.259201939556719,27.931371326317098\n-0.38156147149690905,-0.6149222948003532,24.761123795010576\n-1.4626176759817964,1.4964604004865647,21.27700228639699\n-0.6940045332308884,0.9826324420700231,17.260529465965384\n-0.024194377123757157,-0.16275435957895798,13.033710996411228\n0.4635458299305675,-0.42247283132368973,9.692419613905212\n0.5981546802274386,1.3033874655440214,7.489190005317457\n0.5482403485089431,0.45144142903229056,6.795163417306348\n-0.5338518704828965,0.7891744803114394,8.010272649167938\n-0.8659737009600225,-0.44619651541702093,10.473679735544398\n-0.49033660722471745,-0.1553701276686284,13.47042261332396\n0.5698523853010744,0.1511758434805861,16.80068697116501\n-0.6536568365278388,0.6288685190843082,19.544203017501687\n-0.9970210801573793,-0.5763236329528705,22.393823629033363\n0.13999804159817067,1.6969142391451535,25.728012329735943\n1.0676718209826945,-0.14263667784059747,27.79643946336043\n1.011757445533735,-0.24711108334961432,28.43207435901705\n-0.39467928090499005,0.20551265012544054,27.62183801220909\n-0.2112873801787548,0.7952631222135602,26.330418333864742\n1.0740090522156542,0.024712768451157153,25.322327353014543\n-1.8292916155275667,-0.8021103158347133,25.054808230095624\n-0.2586844383715423,-0.5521383722622872,25.026112812518214\n-0.20507627506905862,-1.3554643837414015,25.36660642300625\n-0.2639141905219191,-0.866894254347671,26.199710634880542\n0.5054075957217706,1.0343356311173906,27.24860316866475\n-1.4226924677350505,1.0801960702920366,28.026307502768024\n-0.5352642710326048,1.0920827290153026,28.44665508994105\n-0.14211738999982745,0.34015925550505877,28.7358132043702\n-1.0797206119474978,2.7080523741344558,29.32205833807738\n0.6578823708968599,1.0928276106281054,29.659936315892878\n-1.6846300997037145,-0.40329223754061283,29.672973426665997\n-0.2540680568872476,0.9933619341116393,29.540272437411335\n0.9757829411750407,0.6698731914581085,29.413455320368936\n0.40134408966062446,-1.696605660828897,29.018430683972777\n0.7974475815145003,-0.47761358680085153,28.72512200229616\n-1.234603421570363,0.6995639625226581,28.38442425927669\n-1.6479133233554248,2.2857093192857896,27.998530951292796\n0.3791323328098722,-1.6815297279626,27.409870238250427\n0.8250696101661925,-0.8849789178557523,26.37508414339917\n1.4665304443947424,0.7212959932704288,24.84264192072054\n-0.5510814879842293,1.2848698832061811,22.912588262569663\n-0.2989274101090755,0.08422114520714842,20.757716151901842\n0.6160646238919407,-1.3171217891979443,20.20386625008502\n-0.3651634882255453,-2.0090028204586248,21.56016050449482\n0.9831561031601885,-2.1048548244227288,24.23848465867955\n1.6367178608091144,3.0455463954384694,27.93876704116081\n-0.14605659258569742,-1.4697399157964457,30.21949601321027\n0.9772960250806593,0.7486455509584807,30.644979370026167\n1.587921505512169,-0.703800327504788,30.134651032618113\n-0.04299625342911187,-0.38813130217051794,28.976933783819153\n-0.8216879678746964,0.41145006184239585,27.4518100154637\n-1.1596889714834637,0.23367977866023393,25.47414344248579\n0.20429625097008852,1.6087344506872527,23.097932747961842\n1.7758689820759108,0.22435086786309438,20.418943198440285\n0.5142610412490953,-0.8385776939103152,16.969795258592935\n-0.06227580505962048,0.9212404915978909,13.003040557311476\n0.36134555562488485,0.20196101821040757,9.170579411340196\n-1.8890253578275749,-0.49915609567803343,6.206767763887687\n0.373551053014874,0.17347527174578428,3.920583583983831\n1.0789447188307992,0.03405620993895411,3.4\n0.3289699821188865,2.698216947967684,5.019990597686778\n0.29905562232166094,0.656858992354978,8.739865914653015\n-1.79874868064852,-0.06107899882440481,14.031000668392975\n0.2514359094062664,-1.8859835553703816,18.87085045583831\n-0.9924137074313091,2.5373304011195508,22.908742699702543\n0.6681156660794709,1.6211905130210658,26.509516849643386\n-1.7162149753968112,1.0419121997700047,29.00458062864626\n1.4823732174562898,-0.6284843754716949,30.126418649750654\n1.4562068730610451,-1.0384528126551766,30.275097298552968\n-0.16250347324599004,0.8299333029994772,29.731869674171932\n-1.7298511164375054,-0.7970034231539387,29.009389698275196\n0.13339416117732042,-0.7844085524316059,28.62118327804196\n0.7879417333273614,-0.2119078018305873,28.1849727882883\n0.055066978008576795,0.1392640126660643,27.601403775474306\n-1.1490206154251696,2.2572927229138195,27.013094754803962\n-1.3359702968758294,2.3808814774592477,26.81927004438\n0.47219390001736106,0.13260344707590266,26.83194515753832\n-0.8627205139104968,-0.23381190458259352,27.70928018696199\n-0.8532298517136189,0.8567829799570981,28.225867144208717\n",fpt); fclose(fpt); char str[100]; FILE *fp; fp=fopen("/tmp/abc123","r"); if(fp==NULL) { return 1; } long double acceleration = 0.0; long double rotation = 0.0; long double temperature = 0.0; long double direction = 0.0; long double v0x = 0.0; long double v0y =0.0; long double max_speed = 0.0; char *sp; char string1[100]; char *end; for(int i=0 ; i<100; i++) { fscanf(fp, "%Lf,%Lf,%Lf", &acceleration, &rotation, &temperature); direction += rotation; long double ax = acceleration * cos(direction); long double ay = acceleration * sin(direction); long double vx = ax + v0x; long double vy = ay + v0y; if(sqrt(vx*vx + vy*vy) > max_speed) { max_speed = sqrt(vx*vx + vy*vy); } v0x = vx; v0y = vy; } printf("Maximal speed %.15Lf",max_speed); fclose(fp); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue