-3

I've seen certain functions declared in this way:

char* encipher(const char *src, char *key, int is_encode);

I don't understand this part:

char* encipher

What do the asterisks after the datatype mean?

clcto
  • 9,530
  • 20
  • 42
Kevin
  • 1,151
  • 1
  • 10
  • 18
  • Because they return a `char*`. – Daniel Kamil Kozar Jul 02 '14 at 21:24
  • 8
    I would suggest it would probably be a good idea for you to find a good C tutorial. – Tripp Kinetics Jul 02 '14 at 21:24
  • If the concern is `char* ` versus `char *`, they are the same. – chux - Reinstate Monica Jul 02 '14 at 21:27
  • 2
    if @Deduplicator's comment is unclear, see [Should “Professionals and enthusiasts” be qualified in the help center?](http://meta.stackoverflow.com/q/258081/1281433). – Joshua Taylor Jul 02 '14 at 21:27
  • This is not a question. This is not even a sentence. **This does not even make sense.** – The Paramagnetic Croissant Jul 02 '14 at 21:28
  • 2
    I'm not quite sure why this question is getting so many downvotes. Yes, it's basic, but it's tough to find answers on this sort of thing if you're completely brand new to the language and don't know what you're looking for. I've seen *way* worse questions on StackOverflow from people who couldn't even be bothered to type out any code at all. – Mike Christensen Jul 02 '14 at 21:34
  • Yes, it is a question and yes, it is a sentence. It makes sense, although the asker seems to be rather a beginner. He may well be an enthusiastic beginner, though. – Rudy Velthuis Jul 02 '14 at 21:39
  • thanks for the compression – Kevin Jul 02 '14 at 21:40
  • @Mike, it's extremely basic and indicates that the OP doesn't know very much about C at all. So, instead of bugging us with basic questions, OP should go hit the books. [Book recommendations here](http://stackoverflow.com/questions/562303). – Tom Zych Jul 02 '14 at 21:49
  • @MikeChristensen: I don't quite get it either. It is IMO a good, specific question, even though the subject is rather at a beginner level. It is not off-topic, it is about C programming, it is not too broad, it is well written and I see nothing wrong with it. I don't understand the close votes either. – Rudy Velthuis Jul 02 '14 at 21:53
  • @TomZych: Sure, the OP seems to be a beginner, but the question is clear, well written and clearly on topic (C language). I see nothing that prevents such questions. – Rudy Velthuis Jul 02 '14 at 21:55
  • @Rudy, @Mike, you are correct: this question is well-written, better than many beginner questions. Nevertheless, the topic is very basic. I glanced at the post referenced by @Joshua and it looks like the consensus is that users should do their own research for basic topics. Granted that it might be hard to search for this if you don't know that `*` means "pointer," but this is introduced fairly early in any C textbook, no? – Tom Zych Jul 02 '14 at 21:59
  • Actually, it looks like nearly all of the quality of this question is due to @Mike's edits. The original question was terrible. – Tom Zych Jul 02 '14 at 22:02
  • it's true, not speak English, used the translator.. – Kevin Jul 02 '14 at 22:08
  • @RudyVelthuis Check the revision history. A number of the downvotes had arrived before "it [was] well written" or "clear, well written and clearly on topic". – Joshua Taylor Jul 03 '14 at 01:35
  • @JoshuaTaylor: OK, I didn't check it yet. Still, I think they were unwarranted. – Rudy Velthuis Jul 03 '14 at 11:15

2 Answers2

6

This just means that the function returns a char *.

John Bupit
  • 10,406
  • 8
  • 39
  • 75
5

The asterisks after the data types mean that a pointer is expected, i.e.

char *src

means that src is a pointer to a char. Pointers are data types that contain addresses to instances of other data types, so a char* contains the address of a char. The first char* means that the function returns such a pointer.

But as others said, you may want to read a good textbook on C first.

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94