Hi all,
I have an exercise in communication systems.

I have to learn about Quantizers.
PCM with Uniform Quantization and with non uniform quantization (Lloyd_MAX algorithm)

When I make this in matlab, I have to compute SQNRS for N=2,4,6 bits.

Does anybody know what I have to expect ?

Thanks a lot

Thanks a lot all!
I did not know about vectors. I am new in C++ programming!

[QUOTE=bufospro;1409235]input
Line 1: [B]20 20 1[/B] 5 6
Line 2: [B]20 21 2[/B] 3 4
Line 3: [B]20 20 1[/B] 4 5
Line 4: [B]20 21 3[/B] 5 6

Line 1 variavle1=20 and variable2=20
I want to search all the file to find another Line that variable1=variable2=20
if it is, then I have to add the values of third variable.

Variable4 and Variable5 I don't care.

So

output
Line 1: 20 20 1+1
Line 2: 20 21 2+3[/QUOTE]

Someone to explain me the basic idea how to do it ? Please

[QUOTE=Fbody;1409213]I think you should clarify what you are trying to do. Either your example output doesn't match your example input making it not make sense or your description of the required actions is too cryptic.

Where did the 5 and 6 go, and where did the 2 come from???[/QUOTE]

input
Line 1: [B]20 20 1[/B] 5 6
Line 2: [B]20 21 2[/B] 3 4
Line 3: [B]20 20 1[/B] 4 5
Line 4: [B]20 21 3[/B] 5 6

Line 1 variavle1=20 and variable2=20
I want to search all the file to find another Line that variable1=variable2=20
if it is, then I have to add the values of third variable.

Variable4 and Variable5 I don't care.

So

output
Line 1: 20 20 1+1
Line 2: 20 21 2+3

Hi all,
I want to read a file.

The file is like that :
20 20 1 5 6
20 21 1 2 3
21 22 2 4 6
20 20 2 3 5
20 21 6 5 2
21 22 1 6 7
....

and I would like every time that I find number1 && number2 in a line to add number3
for example to print
20 20 1+2
20 21 1+6
21 22 2+1

Could you help me please do this ?

I know how to read file but I have not idea how can I do this ?

[CODE]#include <iostream>

include <iomanip>
include <fstream>

using namespace std;

int main()
{
float width,height,var1;
ifstream inFile;
inFile.open("data.txt");

if (!inFile) 
{
      cout << "Unable to open file";
      exit(1);
}

while(inFile)
{
     inFile >> width >> height >> var1;

     cout << width << " " << height << " " << var1 << endl; 
}

inFile.close();

system("pause");
return 0;
}
[/CODE]

Hi all,
I just started to learn prolog.

I wrote some facts and then some rules.
I give to swi-prolog my question and solutions are appearing .

I would like to ask if someone knows which stategy does swi-prolog use ?
backward chaining or forward chaining ?

Can I see somehow all the energies as the final result (with something like print command)?

Thanks a lot

P.S. : I apologise for my english.

[QUOTE=sree_ec;1393341]Which compiler are you using?
Can you paste the Command used to compile your code here?[/QUOTE]

gcc -o server server.c

[QUOTE=gerard4143;1393295]If that's the case your {} error may have thrown off the code parser and as a result generated the _start error...Its working now right?[/QUOTE]

It's problem from the server's compiler you said.
I tried hello world program and the same message appears.

Thanks a lot for our help

My code has main function one time.
I don't know sometimes C make me nervous.

[QUOTE=gerard4143;1393264]Sounds like your code doesn't have a main function...Could you post the code and the compile line.[/QUOTE]

Unfortunately I can't write here all the code from project.
Do you believe that I have forgot a '{' '}' character ?

Hi, I have a problem with my code in C
An error occurs with message :

/usr/lib/gcc/x86_64-redhat-linux/3.4.6/../../../../lib64/crt1.o(.text+0x21): In
function _start': : undefined reference tomain'
collect2: ld returned 1 exit status

Does anyone know for it ?

Thanks a lot

Hi all,
I am trying to read a file in C.

The format of file is something like that :
<From: [email]sender@hotmail.com[/email]>
Hellooooooooo.
</from>
<From: [email]george@gmail.com[/email]>
What am I doing?
nOwwwwwwwwwwwwww
</from>

I would like to read the file and extract some info like
number of emails , senders and messages from email.

I know that I have to open file then reading until eof
but I don't know regular expressions to do this.

Could you help me please ?

[QUOTE=Narue;1387727]Endianness is about byte order, not bit order. So

00000000 00000000 00000000 00000011

in little endian is

00000011 00000000 00000000 00000000

in big endian. Keep that in mind when doing your conversions.[/QUOTE]

thanks a lot

Hi, I found an exercise about memories in a site but I don't understand the solution.

The exercise says :
A word in a little-endian pc has value 3. If I transfer this value in big indian byte per byte what is the new value ?

The answer is 2*(2^24).

I suppose that 3 in little endian is
1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0

and in big endian is
0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1

so the result is 1(2^14) + 1(2^15) = 1 * (2^29)

is this right ?

Hi all,
I have to implement from a general network a virtual ring.

How can I make a vitrual ring ?
Thanks in advance

[QUOTE=sree_ec;1375099]See this code
[code]

strcpy( myaccounts->allaccounts[myaccounts->pos].name,name);

myaccounts->pos ++;

printf("Name = %s\n",myaccounts->allaccounts[myaccounts->pos].name);
[/code]

What you are doing is

  1. Copy the character array to another araray .ie allaccounts[[I]index[/I]].name
  2. Increment [I]index[/I]
  3. Trying to print the value of character array after incrementing [I]index[/I] in step2

which obviously will fail. Try swapping step 2 and 3.[/QUOTE]

Thanks a lot !!

[QUOTE=mitrmkar;1375041]>> No I have %s in my code. Here in the code I forgot it.

Sigh -- then I'm assuming that you may be incrementing the value of [ICODE]pos[/ICODE] too soon (i.e. [I]before[/I] printing).

For future reference, please
[LIST]
[] post [I]the actual code[/I] that seems to be failing
[
] and try to explain how the code fails, i.e. what you expect vs. what happens
[/LIST][/QUOTE]

[CODE]#include <stdio.h>

include <stdlib.h>
include <errno.h>
include <string.h>

int pos;

typedef struct account
{
char fullname[40];
int id;
int amount;
char name[15];
} account;

typedef struct parking_system
{
int pos;
char name[15];
char description[80];
float price;
int busy_lots;
account allaccounts[5];
int id;
} parking_system;

parking_system *myaccounts;

int create(int socket)
{
char name[15];

//here is code that read name from a client 
// the value of variable name is printed ok
//so I write it now like this                       
strcpy(name,"Parking_Name");                    

strcpy( myaccounts->allaccounts[myaccounts->pos].name,name);
myaccounts->pos ++;
printf("Name = %s\n",myaccounts->allaccounts[myaccounts->pos].name);

return 1;
}

int main()
{

create(1);

system("pause");
return 0;
}[/CODE]

[QUOTE=mitrmkar;1374927]>> But when I am trying to pass this value to my struct and then to print it it does not work.

You have forgotten the [ICODE]%s[/ICODE] format specifier, so ..
[CODE]
strcpy( myaccounts->allaccounts[myaccounts->pos].name,name);
/ %s embedded in the format string /
printf("Name = %s\n",myaccounts->allaccounts[myaccounts->pos].name);
[/CODE]

And another question how can I pass value to variable id for example using parking_system ?

Sorry, but I don't understand what that means.[/QUOTE]

No I have %s in my code. Here in the code I forgot it.
Something else goes wrong.

Hi all,
I am trying to make a program but I have a problem. So I can't continue.

I am using a struct like that :

[CODE]typedef struct account
{
char fullname[40];
int id;
int amount;
char name[15];
} account;

typedef struct parking_system
{
int pos;
char name[15];
char description[80];
float price;
int busy_lots;
account allaccounts[5];
int id;
} parking_system;

parking_system *myaccounts;[/CODE]

I have a variable that saves a string like char name[]="NAME";
But when I am trying to pass this value to my struct and then to print it
it does not work.
[CODE]
strcpy( myaccounts->allaccounts[myaccounts->pos].name,name);
myaccounts->pos ++;

printf("Name = \n",myaccounts->allaccounts[myaccounts->pos].name);[/CODE]

And another question how can I pass value to variable id for example using parking_system ?

What am I doing wrong ?
Please help!

[QUOTE=N1GHTS;1368493]I tested this code just to be sure it works. This is a better version of what you were trying to do.
[code]
// This will modify the given string to be cleaned of special characters.
// It will return the given modified cleaned string.

char CleanString(char String) {
char clean = String, // Pointer to the clean part of the string
original = String; // Pointer to the original part of the string

// Go through each character in the original string
for (;original[0]!='\0'; original++) {
switch (original[0]) {
// Rejected Characters
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case '\n': case '\t': case '.': case ',': case '!':
case '?': case ';': case '$': case '@': case '#':
case '%': case '^': case '(': case ')': case '[':
case ']': case '{': case '}': case '&': case '*':
continue;
default: break;
}
// If you got this far, the character is accepted, so
// copy it to the clean part of the string. Then move
// the pointer up one character.
clean[0] = original[0];
clean++;
}

// At the end you will have equal or less than the original
// length of the string. So whatever it is, copy a null
// character to signify the end of the newly cleaned string.
clean[0] = '\0';
return String;
}
[/code]
Using switch statements like this is perfectly fine, especially when the list of rejected characters could ...

[QUOTE=N1GHTS;1368102]I have read this question like 10 times trying to make sense of what you are saying, but I still don't understand.

[B]> The problem I have is that I can't write space in my string.

So strings like : "name fullanme" are rejected
and returns only "name".[/B]

I can't decide which one of these two things you are asking:

1) The program is not letting me type a space character. So what is happening is that strings entered by the user like "name fullname" are being rejected and returning only "name" when it should return the whole string.

2) The program is not allowed to read a space in the string. What is supposed to happen is that strings written like this "name fullanme" are to be rejected
and are supposed to return only "name".

Which is it?[/QUOTE]

I am sorry my english is bad :(
What am I asking is I make a program that reads one string.

If user types [B]$%^&1234prote[/B] then the program I want to save [B]prote[/B]
If user types [B]first! #second@[/B] then the program I want to save [B]first second[/B]
If uses types [B]first second third[/B] then I want to save [B]first second third[/B]
and so on

Hi, I am trying to read a string using the function below.
The problem I have is that I can't write space in my string.
So strings like : "name fullanme" are rejected
and returns only "name".

[CODE]
char getstring(char ret, int max)
{
char ppp, qqq;
int invalid_characters=0;

 //fgets(ret,max,stdin); //it does not work
   scanf("%s",ret);

 for(ppp = qqq = ret; *ppp; ++ppp){

     switch(*ppp){
        case '0':     case '1':     case '2':    case '3':     case '4':   
        case '5':     case '6':     case '7':    case '8':     case '9':
        case '\n':    case '\t':   case '.':     case ',':     case '!':     
        case '?':     case ';':    case '$':     case '@':     case '#':     
        case '%':     case '^':    case '(':     case ')':     case '[':     
        case ']':     case '{':    case '}':     case '&':     case '*': invalid_characters++; 
                  break;

        default: *qqq++ = *ppp; 
                  break;
     }
 }

 *qqq = 0;

return((qqq != ret) ? ret : NULL);
}
[/CODE]

Could you help me please to correct this ?

char ask_if_man_or_woman()
{
      int choice_char;

      do
      {
    printf("\n\t Please press m/M for Man\n");
    printf("\t w/W for Woman\n\n");
    choice_char=getchar();

      }while(choice_char==('w' || 'W' || 'm' || 'M'));
      return choice_char;
}

Thanks a lot
The problem solved using fflush(stdin)

Hi I am implementing a function that check if user is a man or woman.
But it does not worl properly.

I press e for example and appears two times
Please press m/M for Man
w/W for

Also sometimes w/W/m/M are not recognised and appears the above.

My cose is :

[CODE]
char ask_if_man_or_woman()
{
char choice_char;

 printf("Please answer me (w/m)\n");
 scanf("%c",&choice_char);   

 while((choice_char!='w')&&(choice_char!='W')&&(choice_char!='m')&&(choice_char!='M'))
 {
        printf("\n\t Please press m/M for Man\n");
        printf("\t              w/W for Woman\n\n");    

        scanf("%c",&choice_char);   

        printf("\n");
 }

return choice_char;
}[/CODE]

Any ideas please ????

[QUOTE=sundip;1361383]Try
[CODE]cin.flush(); or cin.clear();
fflush(stdin);[/CODE]

at line number 14.[/QUOTE]

Thanks a lot but what is exactly the problem with my code ?
when I am trying only getline function it works.

Hi all,
I am new in c++ programming and I am trying to make some examples
But unfortunately I have some problems

My code is :

[CODE]

include <iostream>
include <string>

using namespace std;

int main()
{
string firstname, lastname, fullname;

    cout << "First name: ";
    cin >> firstname ;
    cout << endl;

    cout << "Last name: ";
    getline (cin, lastname);

    fullname = lastname + ", " + firstname;
    cout << "Fullname: " << fullname << endl;

system("pause");
return 0;
}

[/CODE]

I am using Dev-C++ so the line 'system("pause");'

The problem I have is that getline function does not work.
What am I doing wrong

[QUOTE=pritaeas;1356477]If I try this on jsBin then on hover of the image, Test appears (Opera, jQuery 1.4.2, both without the css and with inline css).[/QUOTE]

Maybe the problem is the version of my Mozilla because it is beta :(

Thanks a lot

[QUOTE=pritaeas;1356455]What goes wrong ? Do you get an error ?[/QUOTE]

Neither Test nor popup window appeared

Hi,
I am trying to learn about JQUERY. So , I found some examples and I am trying to apply to my pages.
But something goes wrong.

Could you help me please ?

For example
1.html
[CODE]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
$(function () {
$('.bubbleInfo').each(function () {
// options
var distance = 10;
var time = 250;
var hideDelay = 500;

var hideDelayTimer = null;

// tracker
var beingShown = false;
var shown = false;

var trigger = $('.trigger', this);
var popup = $('.popup', this).css('opacity', 0);

// set the mouseover and mouseout on both element
$([trigger.get(0), popup.get(0)]).mouseover(function () {
  // stops the hide event if we move from the trigger to the popup element
  if (hideDelayTimer) clearTimeout(hideDelayTimer);

  // don't trigger the animation again if we're being shown, or already visible
  if (beingShown || shown) {
    return;
  } else {
    beingShown = true;

    // reset position of popup box
    popup.css({
      top: -100,
      left: -33,
      display: 'block' // brings the popup back in to view
    })

    // (we're using chaining on the popup) now animate it's opacity and position
    .animate({
      top: '-=' + distance + 'px',
      opacity: 1
    }, time, 'swing', function() {
      // once the animation is complete, set the tracker variables
      beingShown = false;
      shown = true;
    });
  }
}).mouseout(function () {
  // reset the timer if we get fired again - avoids double animations
  if ...

Thanks a lot