Forum: C++ May 21st, 2009 |
| Replies: 10 Views: 547 I meant to say, read it character by character until the end of line or null character. count the white space as an increment also. |
Forum: C++ May 21st, 2009 |
| Replies: 10 Views: 547 since the file being read is a matrix of "i x j". I would read the file first to get the dimension(read the file character by character to get the i), and read the total /n and /0 character to get... |
Forum: C++ Mar 23rd, 2009 |
| Replies: 3 Views: 224 thank you very much! now i remember what the old man was talking about in class! I only have to compile the client program! |
Forum: C++ Mar 22nd, 2009 |
| Replies: 3 Views: 224 |
Forum: C++ Mar 22nd, 2009 |
| Replies: 3 Views: 224 csci>g++ -c queue.cpp
csci>g++ queue.o project6.cpp
Undefined first referenced
symbol in file
Queue<int>::return_index() ... |
Forum: C++ Mar 20th, 2009 |
| Replies: 1 Views: 356 Why won't this let me choose my own array size?
Queue line[qs_pair] is what i'm concern about. As you can see, I have the user input from the terminal the size of the array. But when I compile... |
Forum: C++ Mar 16th, 2009 |
| Replies: 7 Views: 299 thanks everyone, I didn't end up using push_back, but I sure did use vectors!! strange thing is that I never learned vectors in my intro to computer science class. I wonder why? Anyone else have... |
Forum: C++ Mar 15th, 2009 |
| Replies: 7 Views: 299 ok, back with more questions.
what is push_back?
I want to say it is a function, but not certain. |
Forum: C++ Mar 15th, 2009 |
| Replies: 7 Views: 299 thanks, i'll read up more on vectors since I don't understand it. If i run into any more trouble, you'll see me back here :). |
Forum: C++ Mar 15th, 2009 |
| Replies: 7 Views: 299 I don't understand templates very well, but what I'm getting from this is:
for (int i = 0; i < nQueues; ++i)
v.push_back (Queue());
allocates each queue
for (int i = 0; i <... |
Forum: C++ Mar 15th, 2009 |
| Replies: 7 Views: 299 I'm trying to write a a program that simulates a multi queues, multi server such as a grocery line at the grocery store.
The user will enter the desired number of queue/server pair.
how would... |
Forum: C++ Mar 4th, 2009 |
| Replies: 16 Views: 580 well, turns out i only have to compare +,-,*,/ so i created a function to do so.
since +,- are equal and *, / are equal.
we can say:
int Stacks::check_prec(char check)
{
if((int)check == 42... |
Forum: C++ Mar 4th, 2009 |
| Replies: 16 Views: 580 if my stack is like this(with top being at the top of course)
+
*
/
-
and i say (stack->data) > (stack->next->data)
it will read it correctly? |
Forum: C++ Mar 3rd, 2009 |
| Replies: 16 Views: 580 while(!empty_optr()
&& ((top2 -> data_optr == '/'
|| top2 -> data_optr == '*')
|| (top2 -> data_optr == '+'
|| top2 -> data_optr == '-')
&& (top2 -> next2 -> data_optr == '+'
||... |
Forum: C++ Mar 3rd, 2009 |
| Replies: 16 Views: 580 sorry, I should have been more clear. This is my algorithm here.
while(operator stack is not empty AND the top of operator stack is greater or equal precedence AND top of the operator stack is... |
Forum: C++ Mar 3rd, 2009 |
| Replies: 16 Views: 580 I have a linked list of operators
()+-*/ , how would I be able to compare them if they are all of type char? I looked at the ascii table, but they are all out of order so that isn't a choice. |
Forum: C++ Mar 3rd, 2009 |
| Replies: 19 Views: 1,629 omfg!!!! took 2 hours to figure this out. the problem was i didn't set
top2 == NULL!!!!! in stacks.h |
Forum: C++ Mar 3rd, 2009 |
| Replies: 19 Views: 1,629 here is what I have so far
stacks.cpp
#include <iostream>
#include "stacks.h"
using namespace std;
//append a new node with the data to the stack
void Stacks::push_opnd(Item_opnd entry) |
Forum: C++ Mar 3rd, 2009 |
| Replies: 19 Views: 1,629 In your case, x is a single character right? that is what I need. Because I'm doing an infix stack operation on the lines posted above with linked list, so it is important that 'x' being stored... |
Forum: C++ Mar 2nd, 2009 |
| Replies: 19 Views: 1,629 the reason why I'm doing it the way I am is because I'm taking each character and putting it in a linked list stack to be computed.
example of how the file would look like.
5 + 7 * (9 - 6) + 3... |
Forum: C++ Mar 2nd, 2009 |
| Replies: 19 Views: 1,629 ok, the after searching around I found the poblem. The reason why it is not reading the end of line is because the >> operator skips all isspace character. Instead use
inFile.get(x); |
Forum: C++ Mar 2nd, 2009 |
| Replies: 19 Views: 1,629 after fiddling with it, I also notice that it doesn't detect whitespace either. My program is suppose to find the sum of each line, so if i cannot detect the end of line, i cannot get it to work :(. |
Forum: C++ Mar 1st, 2009 |
| Replies: 19 Views: 1,629 i'm writing this on visual studio with vista. I will be transfering it to unix soon. This does not work on neither. |
Forum: C++ Mar 1st, 2009 |
| Replies: 19 Views: 1,629 inFile >> x;
while(!inFile.eof())
{
if(x == '\n')
{
cout << endl;
}
cout << x;
inFile >> x;
} |
Forum: C++ Feb 19th, 2009 |
| Replies: 3 Views: 912 nvm figured it out, i forgot to do temp->next = NULL; before i assigned it to last. |
Forum: C++ Feb 19th, 2009 |
| Replies: 3 Views: 912 void List::remove_last()
{
if(first == NULL && last == NULL)
{}
else
{
Node *temp;
temp = last -> back; |
Forum: C++ Feb 19th, 2009 |
| Replies: 3 Views: 912 void List::remove_last()
{
if(first == NULL)
{
first -> data = ' ';
}
else
{ |
Forum: C++ Feb 19th, 2009 |
| Replies: 8 Views: 655 hm..., i'll email my professor. |
Forum: C++ Feb 19th, 2009 |
| Replies: 8 Views: 655 doesn't work either :(.... it's driving me nuts, i cannot find any errors within the codes. |
Forum: C++ Feb 19th, 2009 |
| Replies: 8 Views: 655 it does the same thing when i compile all 3 files.
g++ list.h list.cpp program4.cpp
list.cpp = implementation file
program4.cpp = client program |
Forum: C++ Feb 19th, 2009 |
| Replies: 8 Views: 655 my other files compiled nicely though. |
Forum: C++ Feb 19th, 2009 |
| Replies: 8 Views: 655 #ifndef LIST_H
#define LIST_H
#include <iostream>
typedef char Item;
class List{
public:
List() |
Forum: C++ Feb 9th, 2009 |
| Replies: 6 Views: 1,617 thank you!! I was wondering why my program kept crashing. |
Forum: C++ Feb 9th, 2009 |
| Replies: 6 Views: 1,617 sure :)
void file(char filename[])
{
List l;
ifstream inputfile;
cout << "enter the name of the file: ";
cin >> filename;
inputfile.open(filename); |
Forum: C++ Feb 9th, 2009 |
| Replies: 6 Views: 1,617 |
Forum: C++ Feb 9th, 2009 |
| Replies: 6 Views: 1,617 ifstream inputfile;
cout << "enter the name of the file: ";
cin >> filename;
inputfile.open(filename);
string temp;
int i = 0;
while(filename != NULL)
{
while(isalpha(filename)) |
Forum: C++ Jan 21st, 2009 |
| Replies: 9 Views: 319 got it working!!! thanks for all the help. again, sorry for my poor typical american english :P |
Forum: C++ Jan 21st, 2009 |
| Replies: 9 Views: 319 thanks agni, i'll try to implement it. |
Forum: C++ Jan 21st, 2009 |
| Replies: 9 Views: 319 the compare function compares the 2 inputs to see if they contain the same alphabetical characters ignoring numbers, punctuations, etc.
if they match up, it'll say: inputs are anagram.
if they... |
Forum: C++ Jan 21st, 2009 |
| Replies: 9 Views: 319 sorry, didn't mean to confuse you.
the user will be asked to enter a sentence(or anything)
then the user will be asked to enter another sentence.
It will then compare the 2 sentence to see... |