Recent content by anonim

  1. A

    Lex and Yacc declared type -- Getting an error

    in .y code: %union{ int ival; int *ivals; char id[20]; char *str; bool *b; } %start START %token COMMENT OP_PLUS OP_MINUS OP_DIV OP_MULT OP_OP OP_CP OP_DBLMULT OP_OC OP_CC OP_COMMA KW_AND KW_OR KW_NOT KW_EQUAL KW_LESS KW_NIL KW_LIST KW_APPEND KW_CONCAT KW_SET KW_DEFFUN...
  2. A

    Using UML Diagrams for Extraordinary Situations

    this user will only use this function when something extraordinary situation, and that's how I stated it in the use case diagram. Is it a bad method of stating this way?
  3. A

    Comp Sci JButton in JPanel with gridlayout

    Is it possible to bring it into this shape using the gridlayout? I use empty label to add this empty gridThis is my code:import javax.swing.*; import java.awt.*; public class test { public static void main(String[] args) { JFrame frame = new JFrame()...
  4. A

    Comp Sci Template for STL in .h File: Error Fix

    in .h file I write like this: namespace board{ template <class T> class BAdapter : public AbstractB{ public: BAdapter(); BAdapter(int x){ x=6; setSize(x); } virtual void setSize(int receivedSize){...
  5. A

    Engineering Circuit Analysis -- How many independent equations can be written using KCL?

    I think there are 4 essential node. So we can write 3 KCL independent equations.
  6. A

    Comp Sci Learning C++: Fixing Class & Vector Error

    I want to create class1. This class will have a private inner class named class2. I want to assign value to member in class2 at first. And I want to create vector<vector<class2>>vec.
  7. A

    Comp Sci Learning C++: Fixing Class & Vector Error

    I am now learning C ++ and trying to learn class and vector. I'm trying to write code, but I got an error. this is my class and enum class: enum class state: char{ empty='.', filled_with_x='x', filled_with_o='o'}; class class1{ private: class class2{ class2()...
  8. A

    Comp Sci Cin.ignore remove first character

    Before this part, I was getting numbers elsewhere using cin. And I add cin.ignore after that and I deleted cin.ignore before getline and it fixed. I'm just seeing your answer, but thank you anyway.
  9. A

    Comp Sci Cin.ignore remove first character

    if(count%2==0){ //for user 1 cout<<"User 1"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something } else if (count%2!=0){ //for user 2 cout<<"User 2"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something...
  10. A

    Comp Sci How to Generate Random Numbers in C++ Using `<random>`?

    I want to generate random numbers in C++. I do not want to use C library function (`<cstdlib> <ctime> (time.h)` ) and class. So I cannot use `rand()` function in C. I want to generate random integer numbers and I guess I can use `<random>` library in C++11. How can I use this generate random...
  11. A

    Comp Sci Creating Huffman Tree with Coding Frequency

    First, I get the string and I find the frequency of the every character. My struct is: typedef struct huffman_tree{ char c; int freq; //unsigned? struct huffman_tree *left; // 0 (left) struct huffman_tree *right; // 1 (right) }huffman_tree; I write this to create Huffman tree...
  12. A

    Comp Sci Using Malloc to Read a File Dynamically

    #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<time.h> int main(){ int index=1; int *arr; int data; char *c; FILE *fp; int input,inp; arr=(int*)malloc(sizeof(int)); fp=fopen("list2.txt","r")...
  13. A

    Comp Sci Troubleshooting String and sscanf in C: How to Get Correct Output | Example Code

    #include<stdio.h> int main(){ char str[]="My first book"; char *a,*b,*c; sscanf(str,"%s %s %s",a,b,c); printf("a=%s b=%s c=%s",a,b,c); } If I write like this, I am getting seg fault
  14. A

    Comp Sci Troubleshooting String and sscanf in C: How to Get Correct Output | Example Code

    #include<stdio.h> int main(){ char str[]="My first book"; char *a,*b,*c; sscanf("%s %s %s",a,b,c); printf("a=%s b=%s c=%s",a,b,c); } I want the output: a= My b=first and c=book. But it does not work, why?
Back
Top