473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

problem: function should have a prototype

I have a problem. function should have a proto type. any body help me..
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<string.h>
  3.   main()
  4. {
  5.  
  6.  
  7.     char arr[10];
  8.     printf("Enter a string to reverse\n");
  9.  
  10.        gets(arr);
  11.  
  12.     streev(arr);
  13.  
  14.        printf("Reverse of entered string is \n%s\n",arr);
  15.  
  16.        return 0;
  17. }
Jan 21 '13 #1
10 3167
Anas Mosaad
185 128KB
line 12, should be strrev instead of streev.
Jan 21 '13 #2
donbock
2,426 Expert 2GB
This didn't cause the error message, but line 3 should be:
Expand|Select|Wrap|Line Numbers
  1. int main(void)
Jan 22 '13 #3
Here function to reverse string is strrev()
and u used streev() which is not defined in libraries of c

Syntax of strrev() is

strrev(string);
Correct code is as follows
Expand|Select|Wrap|Line Numbers
  1.     #include<stdio.h>
  2.     #include<string.h>
  3.       main()
  4.     {
  5.  
  6.  
  7.         char arr[10];
  8.         printf("Enter a string to reverse\n");
  9.  
  10.            gets(arr);
  11.  
  12.         strrev(arr);
  13.  
  14.            printf("Reverse of entered string is \n%s\n",arr);
  15.  
  16.            return 0;
  17.     }
  18.  
  19.  
Jan 24 '13 #4
Anas Mosaad
185 128KB
That's what I said earlier.

@donbock, not sure if your statement is correct. I remember from our C class (more than a decade from now) that we could have a main without an int return type.
Jan 25 '13 #5
Banfa
9,065 Expert Mod 8TB
@Anas Mosaad quite a few C/C++ courses around the world seem to teach that main can return void. The problem is 2 fold

a. They are using an old non-standard compiler that kind of supports this return type.

b. They are wrong. The C/C++ standards* prohibits a return type from main other than int.


* Strictly speaking the C++ standard prohibits a return type from main other than int. The C standard allows a return type other than int (normally void) but this is considered a compiler extension and as such is completely non-portable.

In general it is a good idea to avoid compiler extensions if at all possible as you never know when you may need to use a different compiler and you can't be sure it will have the same extensions.
Jan 28 '13 #6
Anas Mosaad
185 128KB
I agree @Banfa with your post. However I keep my words that the statement should never give such an error as @donbock was trying to says in his post!
Jan 28 '13 #7
donbock
2,426 Expert 2GB
As I said, your "function should have a prototype" error message has nothing to do with your main declaration.

Refer to the C FAQ:
What is the correct declaration of main?
Can I declare main as void?

But what about main's third argument envp?
I believe that declaring void main() can't fail.
So what could go wrong?
The book I've been using always uses void main().
Jan 29 '13 #8
Anas Mosaad
185 128KB
@donbock, I'm not a native English speaker but I think your post #3 is the opposite of #8. I'm not trying to argue you but I'm trying to make sure I understand it well.
You said "This didn't cause the error message, but line 3 should be:". I believe this means that #2 didn't cause the error and the error is should be at line 3. Is this what your statement says? or I misunderstood it?
Jan 29 '13 #9
donbock
2,426 Expert 2GB
What I meant in post 3 was that nothing I was about to say about the proper declaration of main() had anything to do with the error message you reported in your original post.
Jan 29 '13 #10
Anas Mosaad
185 128KB
I misunderstood that statement. Anyway, thanks for the clarification :-)
Jan 29 '13 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Ian | last post by:
The title says it all. I can see the case where a function is to be called directly from C, the name mangling will stuff this up. But I can't see a reason why a template function can't be...
5
by: Alfonso Morra | last post by:
Hi all, I came accross this FP signature and it has me baffled. Can anyone explain this signature to me - i.e what are the input and output types ? void(*(*foo)(int))(int,void(*)(int)) ...
0
by: papigreg | last post by:
Hi, I have made a Windows Forms .Net Project in C++. I use the Philips Speech SDK to make voice recognition on WAV files. In the recognition function, I must pass a pointer of a function which I...
3
by: steven.ke | last post by:
Hi all, I am trying to use the sortBy function in the prototype.js library. Nevertheless, I can't work out what to include in the iterator function. Can someone shed some light on this? Thanks in...
2
by: diverge | last post by:
Hi, i'm working on an ASP project with prototype.js but i just can't get special chars to work as they should. I'm using UTF-8 pages but as soon as i call a page containing for example å,ä,ö, < or...
5
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
1
by: john.swilting | last post by:
I am not good in Javascript I begin I do not understand why my function does not go I post my code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">...
5
by: cyborg81 | last post by:
SOMEONE PLS HELP! im writing this code of a function prototype as follows: #include<iostream> #include<iomanip> using std::cin; using std::cout;
2
LeoTD
by: LeoTD | last post by:
Dear all, I have a problem: I want to execute some codes in page1 and return result in page2. In ASP, the Server.Transfer function is OK. But in PHP, i don't know have function could do it or not....
3
by: ziycon | last post by:
The below function works properly when the its called by: storeExtraImages("n","news",1); But when called by these next two line's it gets to if(move_uploaded_file($_FILES,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.