dE_logics
November 10th, 2009, 03:57 PM
#include <stdio.h>
main()
{
//Notice, whenever I say 'jockey' or 'from', I actually mean input[jockey] and input[from] unless stated explicitly that they are indexes.
/*
Certain lines from the input will be selected for comparison with the rest of the lines...so the program will be separated in 2 parts -
1) Mechanism to select the line
2) Mechanism to compare the selected lines with all the lines below it.
The variables jockey and from will determine which lines are selected...the comparison will run between this and the other lines.
1) Never reset the value of jockey. Search for a \n after the the current value of jockey and proceed to step 2. If '\0' exists instead of '\n', then come out of the loop.
2) The value of from will always be the previous value of jockey + 2...that's cause jockey always points to the end of the new line.
4) Implementing search (algorithm later).
*/
//Input will be stored to this array.
char input[1000];
///make jockey unsigned.
short jockey = -1;
short from = 0;
//Full form -- Search_index, this will work as an increment in value of jockey, the incremented value of jockey will be an element of the next line...since jockey point to a character before '\n', shr_indx's minimum value will be 2.
short shr_indx = 2;
//This variable will store 2 indexes (in a column) of input which are suspected to be duplicates. These indexes will be a part of the duplicate lines.
unsigned char dupes[2][10];
//indexes of dupes
char l = 0;
char m = 0;
//Initiating random value of input.
input[0] = 'g';
//Inputting
printf("\nPaste the list of all contents in /portage/distfiles; this can be generated by running ls while in /portage/disfiles\nEnsure to type a '!' after pasting.\n");
//utilizing variable 'from' temporarily
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
//The line selection mechanism starts
while (input[jockey + 1] != '\0')
{
from = jockey + 2;
///Remove this if.
if(jockey == -1)
jockey = 0;
while(input[jockey] != '\n' && input[jockey] != '\0')
jockey++;
jockey--;
//Searching mechanism starts
/*
The letters from 'from' will be compared with jockey + shr_indx...jockey + shr_indx will point the characters of the line to which the comparison is made, initial value is always 2 no matter what the value of jockey is; these will be the following conditions -
1) If it's identical and equal to '-' proceed to the next step; if they are equal but do not have '-' proceed to step 3; if they are not identical proceed to step 2
1.1) Increment value of srh_index and from and see if both from and jockey + srh_indx points to a number...if so move to next step, otherwise goto step 2.
1.1.1) Export value of srh_indx and from to corresponding columns of dupes and proceed to step 2
2) Increment value of srh_indx to point the next line and goto step 1, if next line does not exist...the array ends, then exit loop but before that set the value of shr_indx to 2.
3) Increment value of srh_indx and from by 1 and proceed to step 1.
*/
//Resetting value of shr_index
shr_indx = 2;
while(input[jockey + shr_indx] != '\0')
{
if(input[from] == input[jockey + shr_indx])
{
if(input[from] == '-')
{
if(input[jockey + shr_indx + 1]>=49 && input[jockey + shr_indx + 1] <= 47 && input[jockey + shr_indx + 1] == input[from + 1])
{
dupes[l][m] = input[from];
m++;
dupes[l][m] = shr_indx;
m = 0;
l++;
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
else
{
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
}
else
{
from++;
shr_indx++;
}
}
else
{
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
}
}
}
Just ignore the comments.
The program get's stuck in this part -
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
according to my diagnosis, it never comes out of the loop...if I make something print out of this loop, it never get printed...for this piece, it's "DID I EVER GET TO THIS STEP???"...it never get executed.
However if I trim the lower parts of the program and make it -
#include <stdio.h>
main()
{
//Notice, whenever I say 'jockey' or 'from', I actually mean input[jockey] and input[from] unless stated explicitly that they are indexes.
/*
Certain lines from the input will be selected for comparison with the rest of the lines...so the program will be separated in 2 parts -
1) Mechanism to select the line
2) Mechanism to compare the selected lines with all the lines below it.
The variables jockey and from will determine which lines are selected...the comparison will run between this and the other lines.
1) Never reset the value of jockey. Search for a \n after the the current value of jockey and proceed to step 2. If '\0' exists instead of '\n', then come out of the loop.
2) The value of from will always be the previous value of jockey + 2...that's cause jockey always points to the end of the new line.
4) Implementing search (algorithm later).
*/
//Input will be stored to this array.
char input[1000];
///make jockey unsigned.
short jockey = -1;
short from = 0;
//Full form -- Search_index, this will work as an increment in value of jockey, the incremented value of jockey will be an element of the next line...since jockey point to a character before '\n', shr_indx's minimum value will be 2.
short shr_indx = 2;
//This variable will store 2 indexes (in a column) of input which are suspected to be duplicates. These indexes will be a part of the duplicate lines.
unsigned char dupes[2][10];
//indexes of dupes
char l = 0;
char m = 0;
//Initiating random value of input.
input[0] = 'g';
//Inputting
printf("\nPaste the list of all contents in /portage/distfiles; this can be generated by running ls while in /portage/disfiles\nEnsure to type a '!' after pasting.\n");
//utilizing variable 'from' temporarily
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
}
"DID I EVER GET TO THIS STEP???" gets printed!!! :o :mad: :confused:
main()
{
//Notice, whenever I say 'jockey' or 'from', I actually mean input[jockey] and input[from] unless stated explicitly that they are indexes.
/*
Certain lines from the input will be selected for comparison with the rest of the lines...so the program will be separated in 2 parts -
1) Mechanism to select the line
2) Mechanism to compare the selected lines with all the lines below it.
The variables jockey and from will determine which lines are selected...the comparison will run between this and the other lines.
1) Never reset the value of jockey. Search for a \n after the the current value of jockey and proceed to step 2. If '\0' exists instead of '\n', then come out of the loop.
2) The value of from will always be the previous value of jockey + 2...that's cause jockey always points to the end of the new line.
4) Implementing search (algorithm later).
*/
//Input will be stored to this array.
char input[1000];
///make jockey unsigned.
short jockey = -1;
short from = 0;
//Full form -- Search_index, this will work as an increment in value of jockey, the incremented value of jockey will be an element of the next line...since jockey point to a character before '\n', shr_indx's minimum value will be 2.
short shr_indx = 2;
//This variable will store 2 indexes (in a column) of input which are suspected to be duplicates. These indexes will be a part of the duplicate lines.
unsigned char dupes[2][10];
//indexes of dupes
char l = 0;
char m = 0;
//Initiating random value of input.
input[0] = 'g';
//Inputting
printf("\nPaste the list of all contents in /portage/distfiles; this can be generated by running ls while in /portage/disfiles\nEnsure to type a '!' after pasting.\n");
//utilizing variable 'from' temporarily
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
//The line selection mechanism starts
while (input[jockey + 1] != '\0')
{
from = jockey + 2;
///Remove this if.
if(jockey == -1)
jockey = 0;
while(input[jockey] != '\n' && input[jockey] != '\0')
jockey++;
jockey--;
//Searching mechanism starts
/*
The letters from 'from' will be compared with jockey + shr_indx...jockey + shr_indx will point the characters of the line to which the comparison is made, initial value is always 2 no matter what the value of jockey is; these will be the following conditions -
1) If it's identical and equal to '-' proceed to the next step; if they are equal but do not have '-' proceed to step 3; if they are not identical proceed to step 2
1.1) Increment value of srh_index and from and see if both from and jockey + srh_indx points to a number...if so move to next step, otherwise goto step 2.
1.1.1) Export value of srh_indx and from to corresponding columns of dupes and proceed to step 2
2) Increment value of srh_indx to point the next line and goto step 1, if next line does not exist...the array ends, then exit loop but before that set the value of shr_indx to 2.
3) Increment value of srh_indx and from by 1 and proceed to step 1.
*/
//Resetting value of shr_index
shr_indx = 2;
while(input[jockey + shr_indx] != '\0')
{
if(input[from] == input[jockey + shr_indx])
{
if(input[from] == '-')
{
if(input[jockey + shr_indx + 1]>=49 && input[jockey + shr_indx + 1] <= 47 && input[jockey + shr_indx + 1] == input[from + 1])
{
dupes[l][m] = input[from];
m++;
dupes[l][m] = shr_indx;
m = 0;
l++;
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
else
{
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
}
else
{
from++;
shr_indx++;
}
}
else
{
while(input[jockey + shr_indx] != '\n' && input[shr_indx] != '\0')
{
shr_indx++;
}
if(input[jockey + shr_indx] != '\0')
shr_indx++;
}
}
}
}
Just ignore the comments.
The program get's stuck in this part -
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
according to my diagnosis, it never comes out of the loop...if I make something print out of this loop, it never get printed...for this piece, it's "DID I EVER GET TO THIS STEP???"...it never get executed.
However if I trim the lower parts of the program and make it -
#include <stdio.h>
main()
{
//Notice, whenever I say 'jockey' or 'from', I actually mean input[jockey] and input[from] unless stated explicitly that they are indexes.
/*
Certain lines from the input will be selected for comparison with the rest of the lines...so the program will be separated in 2 parts -
1) Mechanism to select the line
2) Mechanism to compare the selected lines with all the lines below it.
The variables jockey and from will determine which lines are selected...the comparison will run between this and the other lines.
1) Never reset the value of jockey. Search for a \n after the the current value of jockey and proceed to step 2. If '\0' exists instead of '\n', then come out of the loop.
2) The value of from will always be the previous value of jockey + 2...that's cause jockey always points to the end of the new line.
4) Implementing search (algorithm later).
*/
//Input will be stored to this array.
char input[1000];
///make jockey unsigned.
short jockey = -1;
short from = 0;
//Full form -- Search_index, this will work as an increment in value of jockey, the incremented value of jockey will be an element of the next line...since jockey point to a character before '\n', shr_indx's minimum value will be 2.
short shr_indx = 2;
//This variable will store 2 indexes (in a column) of input which are suspected to be duplicates. These indexes will be a part of the duplicate lines.
unsigned char dupes[2][10];
//indexes of dupes
char l = 0;
char m = 0;
//Initiating random value of input.
input[0] = 'g';
//Inputting
printf("\nPaste the list of all contents in /portage/distfiles; this can be generated by running ls while in /portage/disfiles\nEnsure to type a '!' after pasting.\n");
//utilizing variable 'from' temporarily
while(input[from] != '!')
{
///Remove the ifs
if(from > 0)
from++;
input[from] = getchar();
if(from == 0)
from++;
}
input[from] = '\0';
from = 0;
printf("DID I EVER GET TO THIS STEP???");//DEBUG
}
"DID I EVER GET TO THIS STEP???" gets printed!!! :o :mad: :confused: