Thanks Dean for your kindly support. It worked as expected..Resolving this.

char BinaryFormat(void Input) //Why void*?

Dean, the reason for the above question is, i'm planning to go for generic input case like get input in any format (int, char, ) and trying to converting to binary format..So i used void. This is very initial phase, so i tried with scanf_s("%d", &Input);

DeanMSands3, Thanks for your prompt reply. Let me try your suggestion.

Hi,
I'm facing some problem while returning string. I want to return final string value and print it. Below is the code that i tried,

 int main()
 {
     int Input = 0;

     //Tried using tmpstr also
     //char *tmpStr = NULL;

     scanf_s("%d", &Input);

     //Tried as below also but it was crashing
     //tmpStr = BinaryFormat((void*)Input);

     //Tried as below also but it was crashing and showing only first character
     //tmpStr = (char*)BinaryFormat((void*)Input);
     //printf("\nThe Binary format for the given is : %s",  tmpStr); //It was crashing here

     //Trying to print the number in binary format
     printf("\nThe Binary format for the given is : %s", BinaryFormat((void*)Input) ); //Its crashing here
 }

//
//Coverting the given input to Binary data
//
char* BinaryFormat(void *Input)
{
    char *binFormat = NULL;
    int num = (int)Input;

    //Counting number of bits needed
    int bitCount = BitCount((int)Input); //This will return number of digits needed. This is separate fn

    //Allocating Input based on number of digit(bit value) needed
    //binFormat = (char*) malloc(bitCount*sizeof(char)+1);
    binFormat = (char*) calloc(1,bitCount+1);

    if (Input)
    {
        while(bitCount)
        {
            //Filling binFormat either with 1's or 0's based on number
            binFormat[bitCount-1] = num&1 ? 1 : 0;

            num = num >> 1;
            bitCount--;
        }
    }
    //returning final value as string
    return binFormat;
}

Thanks in advance.

Thanks Moschops for information. I have jpeg imagw which has no end of image (FFD9).

Hi,
I have jpeg image of JFIF type, i want to read jpeg image, decode it and finally i want to display this image in a screen. Could anyone explain me the parsing of jpeg binary data for decoding and encoding?

Thanks in advance

The below is my idea(rough one) to proceed to design first towards implementation.

Create structure for first two data

...........
struct StudentIndex
{
 int No_Of_students;
 int date;
   or
 (int year;
 int month;
 int day;) 
};
..............

Fill this structure by read (using fscanf())
first 2-character for no_of_Students as int
next string(8 character) for date (or read as 4-character for year, 2-char for month, 2-char for day)

fscanf(fp, "%d %s ", structInfo.No_Of_Students,structInfo.date);//Or separte it by year, month, day

Then create struture for studentInfo

............
struct studentInfo
{
 int student ID;
 int course_number;
 char *submission_date; or (sepate date for month, day, year);
};
.............

Fill this structure after filled StudentIndex structure

fscanf(fp, "%d %d %s "", structInfo.Student_ID,structInfo.course_number, structInfo.submission_date);

Once these information is filled you can easily read each data.

Thanks for the quick reply.

Hi Geeks,
 i have declare Char *a type variable and i want to fill data in a[0][n], a[1][n], ... a[max][n]. below is my code snippet which i'm facing build error while initializing.
 I'm getting build error as ".....subscript requires array or pointer type  " 

    .........
            char *a;

            a = (char*)calloc(3,sizeof(int)+3);//trying to allocate for these a[0][5], a[1][5], a[2][5]

            for (int i = 0;i<3;i++)
                for (int j = 0; j<5;j++)
                    a[i][j] = 1;                
    ..........    
--
Thanks in advance.

Hi DeHF,
In your code there is no definition for get_name() and get_salary() function, no initialization in constructor. I modified as below and its behaving fine as u expecting,

#include <iostream>
#include <string>

using namespace std;

class PEmployee
{
public:
    //PEmployee();
    string Name;
    double Salary;
    //Initialization of variable in constructor
    PEmployee(string employee_name, double initial_salary)
    {
        Name = employee_name;
        Salary = initial_salary;
    }
    void set_salary(double new_salary);
    double get_salary() const;
    string get_name() const;
private:
    //Person person_data;
    double salary;
};

//Function definition
double PEmployee:: get_salary() const
{
    return Salary;
}
//Function definition
string PEmployee::get_name()const
{
    return Name;
}

int main()
{
    //PEmployee f;
    PEmployee f("Patrick", 1000.00);
    cout << f.get_name() << " earns a salary of "
        << f.get_salary() << endl;
    return 0;
}
WaltP commented: Thank you for finishing his homework for him. Hope you get a good grade. -3

Hi DeHF,
Post your complete code.

Hi Geek,
Below are my questions in daniweb,

  1. Is there any way to post directly to a person like sending mail to a person so that that person will get notification about that post?
  2. If i'm updating in a particular thread, will it notify the originator of the thread/post/... or he/she needs to open that particular thread/post to check any upadates??
  3. If i'm voting UP/DOWN some thread/post, will the originator of thread/post will get notification about this?
  4. Is there any option to add some geek to my friend list so that i can post to him/her directly at any time without searching his/her name?

    Keep up this good work.

    --
    Thanks in Advance.

Hi Deceptikon,
Below are my opinion. If posting code snippets for below topics wil be useful

  1. Some algorithm, its usage, its appolications with real time example right from the basic algorithms. Then it will be useful for beginners like us to go with some specific(standard) algorithms to implement codings.
  2. Data strutures - when data structure should use? what type of data structure can be use? where can we use data structure? how to use them? etc,.
  3. Memory management related code snippets

    Please keep up this good work.

    --
    Thanks in advance.

Hi,
Which are useful algorithms i implement for simple project??

use strstr(Total_string, String_To_Find) function to find your requied string. This strstr() will returns a pointer to the first occurrence of String_To_Find in Total_string, or a null pointer if String_To_Find is not part of Total_string. with this strstr() you can find number of occurence of your string.

Rithish,
Brief me the wrong output with some example. i dont find any wrong output with this.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    char a[50];
    int n, i = 0;
    printf("enter the string  : ");
    gets(a);
    n=strlen(a);
    printf("The lenght of string is : %d \n",n);
    printf("The reversed string is : ");
    for ( i = (n-1); i>=0; i-- )
    {
        printf("%c",a[i]);
    }

}

my Input is : abc def ghi
output is : ihg fed cba

Hi Rithsh,

the error is at i=n why cant we use i=n;

n is string length value say (string is a[] = Test, lenght n=4). Characters will start at index 0 so string starts like a[0]='T', a[1]='e', a[2]='s', a[3]='t', a[4]='\0'. When you try to print a[4] character then '\0' will print and you need to go till a[0]
I have modified your code with bit changes as below.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    char a[50];
    int n, i = 0;
    printf("enter the string  : ");
    gets(a);//Read string
    n=strlen(a);//Find length of string
    printf("The lenght of string is : %d \n",n);
    printf("The reversed string is : ");
    for ( i = (n-1); i>=0; i-- )
    {
        printf("%c",a[i]);//Printing character from last 
    }

}

Hi geeks,
I'm using visual studio to write and execute programs. I want to create breakpoint not like software breakpoints(F9 for debugging). I want to build the project in release mode and want to have breakpoint. I heard something like _asm int 3 to create breakpoint. Can anyone explain _asm int 3 will do???
Thanks in advance.

Hi Deceptikon,

And before anyone chimes in with swaps using XOR or arithmetic operators that they think are clever: your solution is bad, and you should feel bad.

why one should not use XoR or arithmetic operation to swap number??? can you please explain it?
Then how to swap numbers without using temparory variable.

Hey nitin resolve this post.

Here is the final modified one.

#include <stdio.h>
#include <stdlib.h>

#define BUFFER 100000
#define LINE_BUFFER 200

int glineCount = 0;
typedef struct 
{
    float x, y, u, v;
} PIVPOINT;

// Function Declaration 
void open_vec_file(const char*, PIVPOINT* );

int main()
{
    char fn[] = "PP_B00001.txt";
    int i = 0;

    PIVPOINT *pivp = (PIVPOINT *)malloc(sizeof(BUFFER));

    open_vec_file(fn, pivp);  

    while( i <glineCount )
    {
        printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);
        i++;
    }

    return 0;
}

void open_vec_file(const char *filename, PIVPOINT *pivp)
{

    int i = 0;
    FILE *fp = fopen(filename, "r");
    char fileline[LINE_BUFFER];

    // open the file, first checking if it exists 
    if (fp == NULL){
        printf("ERROR: Could not open vector file %s\n", filename);
    }
    else
    {
        while ( fgets( fileline, LINE_BUFFER, fp) != NULL)
        {
            sscanf( fileline, "%f%f%f%f", &pivp[i].x, &pivp[i].y, &pivp[i].u, &pivp[i].v);
            printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);
            ++glineCount;
            ++i;
        }
    }
    fclose(fp);
}

Hi Benjamin,
I have modified your code bit to access struct member from main function.
To achieve this i passed struct as member to function and declared one global variable to track line count which will be usefull to print the information based on the line count

#include <stdio.h>
#include <stdlib.h>

#define BUFFER 100000
#define LINE_BUFFER 200

int glineCount = 0;
typedef struct 
{
    float x, y, u, v;
} PIVPOINT;

// Function Declaration 
void open_vec_file(const char*, PIVPOINT* );

int main()
{
    char fn[] = "PP_B00001.txt";
    int i = 0;

    PIVPOINT *pivp = (PIVPOINT *)malloc(sizeof(BUFFER)); //Allocating memory before using it

    open_vec_file(fn, pivp);  //Passing struct as extra parameter

    while( i++ <glineCount )
    {
        //printing the structinformation
        printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);
    }

    return 0;
}

void open_vec_file(const char *filename, PIVPOINT *pivp)
{

    int i = 0;
    FILE *fp = fopen(filename, "r");
    char fileline[LINE_BUFFER];

    // open the file, first checking if it exists 
    if (fp == NULL){
        printf("ERROR: Could not open vector file %s\n", filename);
    }
    else
    {
        while ( fgets( fileline, LINE_BUFFER, fp) != NULL)
        {
            sscanf( fileline, "%f%f%f%f", &pivp[i].x, &pivp[i].y, &pivp[i].u, &pivp[i].v);
            printf("point no %d: %f %f  %f  %f\n",i, pivp[i].x, pivp[i].y, pivp[i].u, pivp[i].v);
            ++glineCount; //To fiind the line count
        }
    }
    fclose(fp);
}
  1. typedef int (*HIG) (int,int);

    • a pointer to a function returning an integer.
      In this HIG is pointer to function which taking two arguments first as int and second as int type. And the function HIG return int type.
  2. Is there anyway to use a "sizeof" in a pre-processor macro?
    No. The conditional directives take a restricted set of conditional expressions; sizeof is one of the things not allowed.
    Preprocessing directives are evaluated before the source is parsed (at least conceptually), so there aren't any types or variables yet to get their size.

Post the code what you tried and what are you upto.. so that we can guide you to proceed further.

Hi Harshm,
Follow the below step to enter password using OnScreen Keyboard in Win-7
1.Select Ease of Access on left side fo login screen.
2.Enable vOnScreen Keyboard from the option.
3.Use Softkeyboard to enter ur password.

I hope this will help u. :)

Thanx Deceptiokon for your promptly reply and good comments for respective lines.

Hi deceptikon, what is the content of input file (in your case test.txt). It is nowhere mentioned and no Objective of the program is mentioned. and you have done everything what Sebass wants.
Hey Sebass, how can you build this code without error?? I used VS to build and got more than 20 error excluding warning.It has many build error as deceptikon mentioned.

When execute your code it crashing while initialize ((Matrix+i)+j)=0;
What exactly do you want from this post??

Thank you friends.

Hi,
Anyone suggest/Explain code optimization, time complexity of program. I came across Big O(n), Big O(...). can anyone explain what these means and how to find these for programs.

--
Thanks in advance