![]() |
| | #1 |
| Astrophysics student Join Date: Mar 2009 Location: Netherlands
Posts: 70
| My loop within loop won't work It works fine but now I want the loop within another loop. Once I remove the now commented loop in this code, it doen't show the printf anymore: Code:
//for(i = 0; j < 10; i++)
//{
for (j = 0; j < N_points - 2 ; j++)
{
fgets(string, 512, input);
sscanf(string, "%lf %lf", &spectrum[i].wavelength[j], &spectrum[i].intensity[j]);
printf ("\n %d\t%g \t%g", j, spectrum[i].wavelength[j], spectrum[i].intensity[j]);
}
//}
__________________ Nothing to see here, move along... |
| Ayreon is offline | |
| | #2 |
| CSharpener Join Date: Oct 2006
Posts: 5,556
| i = 0; j < 10; i++)
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. |
| vart is offline | |
| | #3 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 12,459
| Use a debugger. Maybe N_points <= 2, so the loop never runs at all. EDIT: Oh wait, once you remove the comments it does not work... haha, ok, vart is probably on the right track here.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #4 |
| Astrophysics student Join Date: Mar 2009 Location: Netherlands
Posts: 70
| Thanks vart, that was the problem . Needed a fresh pair of eyes apparently.
__________________ Nothing to see here, move along... |
| Ayreon is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| loop the loop - feeling foolish | estos | C Programming | 2 | 04-07-2007 02:45 AM |
| A mini-compilier I made stuck in an infinite loop (lots of code) | dan06 | C++ Programming | 1 | 10-27-2006 01:21 PM |
| The Bludstayne Open Works License | frenchfry164 | A Brief History of Cprogramming.com | 8 | 11-26-2003 11:05 AM |
| fopen(); | GanglyLamb | C Programming | 8 | 11-03-2002 12:39 PM |
| for loop or while loop | slamit93 | C++ Programming | 3 | 05-07-2002 04:13 AM |