473,396 Members | 2,147 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,396 software developers and data experts.

Some odd place to declare

Is this valid in C99:

int main(void)
{
printf("%s\n", char *p = foo());
return 0;
}

char *foo()
{
return "abc";
}

Jul 18 '07 #1
2 1201
Ravi wrote:
Is this valid in C99:

int main(void)
{
printf("%s\n", char *p = foo());
return 0;
}

char *foo()
{
return "abc";
}
No.

--
Ian Collins.
Jul 18 '07 #2
On Wednesday 18 Jul 2007 1:47 pm, in comp.lang.c, Ravi
<ra*********@gmail.comwrote:
Message ID: <11*********************@e9g2000prf.googlegroups.c om>
Is this valid in C99:

int main(void)
{
printf("%s\n", char *p = foo());
return 0;
}

char *foo()
{
return "abc";
}
No. It will not compile. Even if you correct it to do so, it still
invokes undefined behaviour.

Jul 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Daniel Schüle | last post by:
Hi all I have 2 questions 1) is there a way do declare static variables in a class? I coded this logic in global variable foo_cnt 2) is there a way to see the types of all data/function...
3
by: gopal srinivasan | last post by:
Hi I am novice to XML, but I am excited abt XML. I have few queries 1. Can XML read the data from any database. If yes, then Suppose I have a MSAccess database and i have say some 5 tables....
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
2
by: Black Ninja | last post by:
''''''''''''''The class needs to be called clsRAS, paste the following Imports System.Runtime.InteropServices Public Class ras Private Const RAS_MaxEntryName As Integer = 256 Private Const...
11
by: Frank | last post by:
Hello, I need one specific value in all the applicationspecific forms and classes of my application. What is the proper place to put it? At the moment I use a module with a public constant and...
5
by: vivekian | last post by:
Created a class , which is declared within a namespace . namespace mySpace { class X { /* members */ } This class task is to be used by another class Y , 'using namespace mySpace' directive.
20
by: Mukesh | last post by:
Hi all, Consider this code SqlConnection oConn = new SqlConnection(AccountsConnectionString); SqlCommand cmdInsert = new SqlCommand("UpdateQuery"); //Location 1: //SqlTransaction sqlTran =...
2
by: Todd | last post by:
Hi, My company is switching from Microsoft SQL 2005 to IBM DB2 UDB 9.1. I've been playing around with the environment on and off for about two weeks now in my spare time, and have a bunch of...
4
by: marcus hall | last post by:
I am considering a strategy for implementation of a finite state machine. What I would like to do is to use derived classes to represent the state of the machine, so the vtable pointer is the state...
3
by: bnashenas1984 | last post by:
Hi everyone I'v been programming a simple task and process manager which is working fine now but the problem is that my program does NOT work on some computers. I think it must have something to do...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.