473,378 Members | 1,495 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,378 software developers and data experts.

didnt terminate

I have send my code,It print some no without ending.but i cant found the fault point can u help me


Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char *argv[])
  5.   {
  6.     int i;
  7.     int j;
  8.     int k;
  9.     int m;
  10.     int ptr;    
  11. k=0;
  12. printf("0");
  13. putchar('\n');
  14.     for(i=2;i<argc;i++)
  15.    {
  16.     for (j=1;j<i;j++)
  17.     {    
  18.     ptr = strcmp(argv [j], argv[i]);
  19.     if(ptr==0)
  20.     {
  21.  
  22. argv[i]=argv[i+1];
  23. i--;
  24. printf("%d",(j-1));
  25. //putchar('\n');
  26. goto loop;
  27.     }
  28. }
  29. {
  30. k++;
  31. printf("%d",k);
  32. loop:
  33. putchar('\n');
  34. }
  35. }
  36. return 0;
  37. }
Jul 12 '07 #1
4 1441
weaknessforcats
9,208 Expert Mod 8TB
for(i=2;i<argc;i++)
{
etc...
argc?

That's the number of arguments on the command line. There must be at least 3 arguments or this loop will run forever.

I do not understand your logic here. What are you trying to do?
Jul 12 '07 #2
argc?

That's the number of arguments on the command line. There must be at least 3 arguments or this loop will run forever.

I do not understand your logic here. What are you trying to do?
Hi!
I enter arguments at the run time (./a.out {aa,bb,aa,cc,de,dg,cc,cc,jhe}) like this.I use this code for numbered those string and if there are 2 or more string in same I wanna put a same index for that.So required o/p for above set is (0,1,0,2,3,4,2,2,5) like this.Your help is highly appreciate & pls help me to solve this,bcos still I couldnt solve this.
Thanks
Jul 16 '07 #3
Darryl
86
Look at line 14, then look at line 23 above.

i++ and i-- = loop forever!!!
Jul 16 '07 #4
JosAH
11,448 Expert 8TB
Also see this thread.

kind regards,

Jos
Jul 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: abovetreeline | last post by:
Hi, How to make javascript terminate a win32_process? vbscript will terminate a named process with the following code: strcomputer = "." Set objwmiservice = GetObject("winmgmts:" _ &...
9
by: liangbowen | last post by:
As i konw, the only way to to terminate a thread started by _beginthread() is to user _endthread() (or return) inside the thread. now i started a thread(TodoThread), and created a listenning...
4
by: Dr. J | last post by:
How to terminate a blocked thread? In my form's "load" I launch a TCP listening thread that stays in an infinite loop waiting for incoming TCP packets. In this form's "closing" I try to...
3
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
3
by: Peter Neuburger via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Peter Neuburger Hi Everybody, I need some help with the WMI Terminate Method. I have a Listbox where I get all the Process...
7
by: fyi85 | last post by:
I have 8.1.5 on Windows 2003, when I do from CLP with auto commit off: db2 update table set column=something and then db2 terminate and then db2 connect to db db2 select updated column from...
2
by: Draw | last post by:
I have an application, where I do connect, handle a few requests, and if for some reason, I lose connectivity, I detect that and loop(trying to reconnect) until I regain connection to the DB. My...
3
by: Laurence | last post by:
Hi there, Does anyone know what's difference among "connect reset", "disconnect", and "terminate"? Thanks in advance,
1
by: Justin | last post by:
We had a load that failed. Now we have a pending load. When executing load terminate, we receive the following error: db2 load terminate SQL0104N An unexpected token "terminate" was found...
2
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P =...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.