7 Replies - 859 Views - Last Post: 30 November 2011 - 11:17 AM Rate Topic: -----

#1 jink  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 59
  • Joined: 10-July 11

void value not ignored as it ought to be

Posted 30 November 2011 - 12:49 AM

I got the following error for my code.i searched for similar previous posts but i dont seem to be having the same problem.my code is
#define N 6
#include<stdio.h>
#include "itoa_recursive.c"
#include "rvs.h"
#include "ptl.h"
main() 
{
      int i=0;
      extern void itoa;extern void rvs;extern void ptl;
      int m=235;char number[N];
      itoa(m,number,i);
      rvs(number);
      ptl(number);
      gethcar();
      }
program itoa_recursive.c is for converting integer to character array with the use of recursion.And the main program is for testing whether this has happened.rvs.h is a header created by me which has a function which reverses an array.ptl is a header created by me which has a function which prints out the contents of an array given the pointer to the array.i am only getting the error
C:\jink\dev_cpp\k&r4-12.c In function `main':
11 C:\jink\dev_cpp\k&r4-12.c void value not ignored as it ought to be
12 C:\jink\dev_cpp\k&r4-12.c void value not ignored as it ought to be
13 C:\jink\dev_cpp\k&r4-12.c void value not ignored as it ought to be
All the three functions are not returning any value to any variable still i have that error.

Is This A Good Question/Topic? 0
  • +

Replies To: void value not ignored as it ought to be

#2 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 473
  • View blog
  • Posts: 1,524
  • Joined: 20-March 10

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 02:06 AM

Why is i=0; shouldnt it be i= 10; ??

Why are you declaring functions extern void ??

Then plugging numbers into them ??

Therefore bringing about the error

void value not ignored as it ought to be

shouldn't it be extern void itoa(int n, char c, int k);

or similar

and you do know itoa is a keyword in C++ ??

Have a think..

Best Wishes Snoopy.
Was This Post Helpful? 1
  • +
  • -

#3 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1688
  • View blog
  • Posts: 2,553
  • Joined: 21-June 11

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 03:47 AM

View Postsnoopy11, on 30 November 2011 - 11:06 AM, said:

and you do know itoa is a keyword in C++ ??


No, it's not.
Was This Post Helpful? 0
  • +
  • -

#4 jink  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 59
  • Joined: 10-July 11

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 04:25 AM

thank you.i understood,i was declaring them like variables.compiler took that they take no arguments.also i forgot to add a comment that i is the position in the array which is yet to be filled.so initially it should be 0.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5662
  • View blog
  • Posts: 22,506
  • Joined: 23-August 08

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 04:51 AM

#include "itoa_recursive.c"


NO!!! This is NOT how you compile in a second source file. You add the second source file to your project.
Was This Post Helpful? 2
  • +
  • -

#6 jink  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 59
  • Joined: 10-July 11

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 10:43 AM

sorry,i didnt get you.can you please explain or give some link where
1.how to add different files(source or header) to the main function.
2.how to declare or define the funtions involved in the files in main.
3.i have never worked with project.what is it?when is it necessary?(i have just started programming)
is given in detail.
Was This Post Helpful? 0
  • +
  • -

#7 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 473
  • View blog
  • Posts: 1,524
  • Joined: 20-March 10

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 11:15 AM

JackOfAllTrades meant

You dont #include .c files or .cpp you only #include .h or .hpp files

with .c and .cpp files you add them via.

Now this depends on your IDE, for Code::Blocks

its File -> New -> File then select C/C++ file

select in this case C file and it will open a window and put your .c file

into your current project.

Best Wishes

Snoopy.
Was This Post Helpful? 2
  • +
  • -

#8 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5662
  • View blog
  • Posts: 22,506
  • Joined: 23-August 08

Re: void value not ignored as it ought to be

Posted 30 November 2011 - 11:17 AM

IDEA: Read the documentation for whatever IDE you're using to write your program. In your case this appears to be the crappy, outdated, unsupported Dev-C++.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1