Computer programmers

Joined
Apr 1, 2009
Messages
18,297
Reaction score
1,007
I could use some help. How would tackle this?
There are like 17 bins at work filled with miscellaneous parts like resistors, diodes, connectors and such. I have to create a program to make it easy forpeople to search through looking for what they want. I've made separate .txt files with a list of the sizes of the parts and what bin, column, and row theyare located in, and in my code which is C btw. I've just done simple command prompts like "press 1 for resistors" and then the .txt file pops upwith the resistors.
This seems like a really brute force way of doing it. Is there any easier/better looking way of doing this?
I would copy and paste my code but it's on my computer at work and I don't feel like doing it over again from home
 
You can use MS Access to create a database of all that stuff (whatever is in those .txt files) then create an interface for searching through it. Voila
 
I don't think Access is on the computers there, otherwise I'm sure they would of let me known about that. least I hope they would of.
I'll check that out tomorrow, thanks
 
yeah they don't have Access.
can anyone help me with this, idk what i did it was working kinda fine now it's acting all weird. it's not completely done but that's the base ofwhat I want it to look like.
Switch-Case to read in the files. then on the first case I wanted to do a nested switch-case, and I'm pretty sure thats what effed it all up.


// switch.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include

int _tmain(int argc, _TCHAR* argv[])
{
int choice;
char item='1';
char x, nest;



printf("Select what you would like to search for
first1--Resistors2--Capacitors3--Connectors4--Other5
--Quit");
scanf("%c", &item);
fflush(stdin);

switch(item)
{

case '1':

printf("What range of Resistors
are you looking for?A--1 ohm - 1.0M ohB--Other");
scanf("%c", &nest);
fflush(stdin);
switch(nest){

case 'A':
FILE *resistors;

resistors=fopen("C:\\Documents
and Settings\\Duncan-WD\\Desktop\esistors.txt", "r");
if(resistors==NULL)
{
printf("error opening
file");

return 0;
}
else

while(1)
{
x=fgetc(resistors);
if(x!=EOF)
{
printf("%c", x);
}
else
{
break;
}
}
printf("");
fclose(resistors);
break;
break;

case 'B':
FILE *resistors2;

resistors2=fopen("C:\\Documents
and Settings\\Duncan-WD\\Desktop\esistors2.txt", "r");
if(resistors2==NULL)
{
printf("error opening file");

return 0;
}
else

while(1)
{
x=fgetc(resistors2);
if(x!=EOF)
{
printf("%c", x);
}
else
{

}
}
printf("");
fclose(resistors2);
break;
break;
}//end nested



case '2':
fflush(stdin);
FILE *capacitors;

capacitors=fopen("C:\\Documents and
Settings\\Duncan-WD\\Desktop\\capacitors.txt", "r");
if(capacitors==NULL)
{
printf("error opening file");

return 0;
}
else



while(1)
{
x=fgetc(capacitors);
if(x!=EOF)
{
printf("%c", x);
}
else
{

}
}
printf("");
fclose(capacitors);



case '3':

FILE *connectors;
connectors=fopen("C:\\Documents and
Settings\\Duncan-WD\\Desktop\\connectors.txt", "r");
if(connectors==NULL)
{
printf("error opening file");

return 0;
}
else

while (1)
{
x=fgetc(connectors);
if(x!=EOF)
{
printf("%c", x);
}
else
{
break;
}
}
printf("");
fclose(connectors);

case '4':

FILE *other;

other=fopen("C:\\Documents and Settings\\Duncan-WD\\Desktop\\other.txt",
"r");
if(other==NULL)
{
printf("error opening file");

return 0;
}
else



while(1)
{
x=fgetc(other);
if(x!=EOF)
{
printf("%c", x);
}
else
{
break;
}
}
printf("");
fclose(other);


case '5':
printf("Thanks, Goodbye");

}//end switch





return 0;
 
Back
Top Bottom